Commit Graph

841 Commits

Author SHA1 Message Date
Jelle Zijlstra
6f2c53f3b0 _imp: fix stubtest issues, add Python 3.11 items (#7878) 2022-05-19 14:43:58 +02:00
Alex Waygood
44d33f2fdb Add colour to the output of mypy_test, take 2 (#7879)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2022-05-19 13:29:15 +01:00
Jelle Zijlstra
250f3d92e7 ast: fix stubtest issues (#7877)
Add annotations for `_ast.Tuple.dims` and `ast.main()`. Add allowlist comments for others.
2022-05-19 10:13:08 +01:00
Atsu Kakitani
d389b5f9cb Import SQLAlchemy types in Flask-SQLAlchemy (#7861) 2022-05-19 08:19:49 +02:00
Jelle Zijlstra
4191906e6e 3.11: move some stubtest entries to wontfix list (#7876) 2022-05-19 08:14:44 +02:00
Alex Waygood
04dde4d000 enum: More changes for 3.11 (#7862) 2022-05-18 19:35:22 -07:00
Alex Waygood
a348dac6e7 Revert "Add colour to the output of mypy_test" (#7874)
Revert "Add colour to the output of `mypy_test` (#7872)"

This reverts commit 753eb053ac.
2022-05-18 17:13:06 -07:00
Alex Waygood
753eb053ac Add colour to the output of mypy_test (#7872)
And gracefully exit on KeyboardInterrupt.
2022-05-19 00:36:59 +01:00
Sebastian Rittau
3aaa1d0ada Upgrade pyright to 1.1.247 (#7867) 2022-05-18 19:56:19 +01:00
Sebastian Rittau
7ca82d5fb4 stubtest third party: remove extra line when skipping a distribution (#7864) 2022-05-18 20:15:55 +02:00
Alex Waygood
a98a1ead06 Improve output of mypy_test when reporting errors (#7863) 2022-05-18 19:10:54 +01:00
Jelle Zijlstra
7998906226 re: 3.11 fixes (#7859) 2022-05-17 21:42:23 -07:00
Jelle Zijlstra
bd394d2486 builtins: add BaseException.add_note in py311 (#7860) 2022-05-17 20:32:28 -07:00
Jelle Zijlstra
a01f98c361 sqlite3.Blob: fix stubtest errors (#7858) 2022-05-17 19:50:19 -07:00
Jelle Zijlstra
8f5a83516b tempfile.SpooledTemporaryFile: inherit from IOBase on 3.11 (#7802)
python/cpython#29560

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-05-17 18:41:47 -07:00
Jelle Zijlstra
eab82c838a asyncio: updates for 3.11 (#7844)
CPython changes:

- 13c10bfb77
- 9523c0d84f
- 9f04ee569c
- d03acd7270
- 195a46d6ff

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-05-17 18:11:29 -07:00
Sebastian Rittau
b65ef3a722 Make third party stubtest output more succinct (#7853)
stubtest_third_party.py will now only print a single line when the test
succeeds for a certain distribution, unless the "-v" option is given.
When the test fails or "-v" is given, will still print the full output.

The success status is now colored to make spotting failures easier.

stdout/stderr is now used consistently: The distribution name and
success status is always printed to stdout, all other output goes to
stderr. Running the script with "2>/dev/null" will only show the success
status of the test, one per line.
2022-05-17 16:10:58 -07:00
Alex Waygood
171ea08f0d Add __class_getitem__ to classes in logging and csv (#7830)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-17 14:12:42 +01:00
Shantanu
cb45a4387f stubtest: organise allowlists (#7847)
Co-authored-by: hauntsaninja <>
2022-05-16 21:29:39 -07:00
Shantanu
b445bb8856 stubtest: test against 3.11 (#7845) 2022-05-16 19:50:30 -07:00
Shantanu
05c929d42c stubtest_stdlib: [minor] remove unused code (#7846)
Co-authored-by: hauntsaninja <>
2022-05-16 19:40:46 -07:00
Rick Voormolen
693c4f19b4 Mark Future._callbacks as a @property (#7829) 2022-05-11 11:13:29 +02:00
Shantanu
468d8adff1 stubtest_third_party: show package versions on failure (#7826)
Co-authored-by: hauntsaninja <>
2022-05-11 08:08:02 +02:00
Alex Waygood
f8547a3f31 Use flake8-pyi 22.5.0, remove redundant parts of check_new_syntax (#7821) 2022-05-10 09:34:41 -07:00
Jelle Zijlstra
5c13f8bbce ast: FormattedValue.conversion cannot be None (#7810)
```
In [4]: ast.dump(ast.parse('f"{x!r}"'))
Out[4]: "Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=114)]))], type_ignores=[])"

In [5]: ast.dump(ast.parse('f"{x}"'))
Out[5]: "Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=-1)]))], type_ignores=[])"
```
(On 3.9 but I don't think this has changed since 3.6.)

The stdlib also assumes this: https://github.com/python/cpython/blob/main/Lib/ast.py#L1211 (`chr(None)` doesn't work).
2022-05-08 19:42:38 -07:00
Alex Waygood
8d8420bc54 Fix bugs in check_new_syntax.py (#7808) 2022-05-08 21:59:19 +01:00
Alex Waygood
bb39bdfd30 Add test cases for pow that are meant to fail a type check (#7760) 2022-05-08 08:16:37 -07:00
Alex Waygood
3ed7e3ba50 csv: annotate keyword arguments in various functions and methods (#7788) 2022-05-07 21:01:20 -07:00
Alex Waygood
c6b3211afa Improve test-suite documentation (#7756)
- mypy_test and pyright no longer just test the stubs, they now also test other parts of typeshed as well.
- pytype_test.py can now be run on 3.10, meaning the whole test suite can now also be run on 3.10.
- Various test scripts now have from `__future__ import annotations`, meaning they can now only be run on 3.7+.
- Clean up the description of pyright_test.py, which had a slightly confusing wording.
- Also fix the `--dry-run` config option in mypy_test.py, which I accidentally broke in #7746
2022-04-30 12:43:48 -06:00
Alex Waygood
8b118b236d Run mypy on the test cases and test scripts (#7746) 2022-04-30 06:39:07 -06:00
Alex Waygood
9d450cb50c Make test scripts pass mypy --strict (#7745)
- Add several type hints to untyped functions.
- While we're at it, upgrade several annotations to use modern syntax by using `from __future__ import annotations`. This means that the tests can't be run on Python 3.6, but 3.6 is EOL, and it is already the case that some scripts in this directory can only be run on more recent Python versions. E.g. `check_new_syntax.py` uses `ast.unparse`, which is only available in Python 3.9+.
- Fix a few pieces of code that didn't type check.
2022-04-29 21:55:12 -06:00
Alex Waygood
002c8e2586 Cleanup mypy_test.py (#7738) 2022-04-28 12:00:54 -06:00
Akuli
bfa918880f asyncio: expose WriteTransport.get_write_buffer_limits on all Python versions (#7718) 2022-04-27 16:38:25 +03:00
Sebastian Rittau
02310d93da Update pyright to 1.1.240 (#7701) 2022-04-27 15:02:30 +02:00
Sebastian Rittau
f7aa41245e Drop Python 2 support in third-party stubs (#7703) 2022-04-27 15:32:17 +03:00
Rebecca Chen
2116d2425e Remove paramiko stubs from pytype_exclude_list. (#7669)
Pytype can parse these now.
2022-04-20 21:53:54 +01:00
Sebastian Rittau
499e74cf2a Add wsgiref.types (Python 3.11+) (#7644)
_typeshed.wsgi: Import from wsgiref.types in Python 3.11+

Make types match wsgiref.types
2022-04-16 21:36:31 +02:00
Jelle Zijlstra
b0611bc031 Improve sqlite3 types (#7641)
Read through the code in CPython and made the types more precise
where possible.

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2022-04-16 11:20:11 -07:00
Alex Waygood
819900fa55 Python 3 stubs: use str instead of typing.Text (#7638) 2022-04-16 15:47:00 +01:00
Alex Waygood
a1b1b95f67 Unpin Python micro versions used by stubtest (#7619)
Add new `asyncio` method, fix allowlists
2022-04-13 22:07:01 +02:00
Rebecca Chen
f1856a384e pytype_test: Don't mix up stdlib and stub packages starting with stdlib. (#7609)
This should fix the pytype_test failure in
https://github.com/python/typeshed/pull/7608.
2022-04-08 13:01:37 -07:00
Alex Waygood
478e7527aa mypy_test: Add two more config options (#7560)
`--enable-error-code ignore-without-code` means that mypy will ignore any type: ignore comments that don't have mypy error codes. It doesn't appear to have any effect on type: ignore comments that mypy_test doesn't use (e.g. because they're pyright- or stubtest-specific).

`--strict-equality` means that mypy will raise errors if we do something silly like `if sys.version_info == "linux"`. flake8-pyi should also check this for us, but I don't see any reason not to have mypy check this as well.
2022-03-28 16:06:13 +01:00
Stefan Zabka
f40747f81d Add Server to asyncio.base_events' __all__ (#7554)
Add Server to asyncio.base_events' __all__

Closes #7552
2022-03-25 20:32:28 +00:00
Alex Waygood
5c44ae4f8c Improve various signatures that shouldn't be async def, but currently are (#7491)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2022-03-18 20:54:39 -07:00
Alex Waygood
3ab250eec8 Use PEP 604 syntax wherever possible (#7493) 2022-03-16 16:01:33 +01:00
Alex Waygood
15e21a8dc1 Use pyright 1.1.230 in CI, temporarily pin pyright-action to 1.0.4 (#7495)
* Upgrade pyright to 1.1.230
* Add `type: ignore`s for new pyright checks regarding multiple inheritance
* Temporarily pin pyright-action to 1.0.4, as changes made in 1.0.5 break typeshed's CI

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-16 14:24:55 +00:00
Sebastian Rittau
fdc5863337 Use stubtest 0.941 (#7490) 2022-03-15 00:37:34 -07:00
Alex Waygood
2f338ce077 Further improve mypy_test.py (#7484)
* Run mypy on the 3.11 stdlib in CI, as a regression test for https://github.com/python/mypy/issues/12220
* Correct the docstring at the top of the file following the changes made in #7478
* Stop the test from crashing when run locally if there's an extra file/folder in the stubs directory.
2022-03-13 19:58:30 +00:00
Jelle Zijlstra
fa332220b7 Fix mypy test (#7478)
* Fix `mypy_test.py` so that it actually tests the third-party stubs
* Upgrade to mypy 0.940
* Skip running mypy on `SQLAlchemy` stubs for now, to workaround a mypy crash.

Because we didn't set mypy's clean_exit parameter, it was exiting immediately after checking the stdlib, meaning `mypy_test.py` wasn't checking the third-party stubs at all.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-03-13 13:01:14 +00:00
Sebastian Rittau
cdb573b398 Remove explicit inheritance from object (#7468) 2022-03-09 19:43:44 +01:00