Alex Waygood
c05731c46f
tempfile.pyi: readability improvements (#7959 )
...
The name `_DirT` implies that it is a `TypeVar`, but it isn't; it's a generic `TypeAlias` that can be parameterised with a `TypeVar`. Rename it to just `_Dir` instead.
Also, use aliases instead of repeating incredibly long Literal annotations six times.
2022-05-27 08:52:44 +01:00
Alex Waygood
d511312e21
multiprocessing.managers: fix TypeVar usage (#7938 )
...
#7928
`dict()` and `list()` just return empty dictionaries and lists (respectively) if no arguments are supplied:
```python
>>> from multiprocessing.managers import SyncManager
>>> with SyncManager() as s:
... print(s.dict())
...
{}
```
2022-05-26 07:18:43 -07:00
Alex Waygood
fa636bc044
Third-party stubs: fix several fictitious type aliases ( #7958 )
2022-05-26 06:26:26 -07:00
Alex Waygood and Jelle Zijlstra
cb7742e12c
tempfile: Fix TypeVar usage (#7939 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com >
2022-05-25 20:06:46 -07:00
Alex Waygood
ac9efd8573
stubtest_stdlib: run on PRs updating requirements-tests.txt (#7949 )
2022-05-25 15:29:05 +02:00
Alex Waygood
54e11a1ec4
mypy_extensions: fix TypeVar usage (#7937 )
...
#7928
2022-05-24 11:26:35 -07:00
Alex Waygood
76a4bd796b
Simplify and correct many numeric unions ( #7906 )
...
Unblocks PyCQA/flake8-pyi#222
2022-05-21 15:25:00 +01:00
Alex Waygood
aa70cc8abb
CI: Don't install tomli for stubtest_stdlib ( #7901 )
...
The script doesn't import tomli
2022-05-20 19:33:06 -07:00
Alex Waygood
d54d018e2d
CI: Fix stubtest workflow; make paths for other workflows more specific ( #7897 )
2022-05-20 16:37:02 +01:00
Alex Waygood
e2cf6c21d5
CI: Don't run stubtest_stdlib on PRs that don't touch the stdlib ( #7895 )
...
* Don't run stubtest_stdlib on PRs that don't touch the stdlib
2022-05-20 15:56:29 +01:00
Alex Waygood
dd080d9840
Upgrade flake8-pyi to 22.5.1 ( #7882 )
2022-05-19 19:59:25 +02:00
Alex Waygood
aa72cb1dcf
Run pyupgrade on the tests directory ( #7880 )
2022-05-19 14:16:53 +01:00
Alex Waygood and Sebastian Rittau
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
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
Alex Waygood
a98a1ead06
Improve output of mypy_test when reporting errors ( #7863 )
2022-05-18 19:10:54 +01:00
Alex Waygood and Jelle Zijlstra
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
Alex Waygood
eadb35e620
Don't run mypy_primer on changes to test files ( #7854 )
...
Only changes to files in `stdlib` or `stubs` will ever have any effect on the checked open-source code. But also run primer on changes to files in `.github/workflows` so that we can see the effect of changes to the `mypy_primer.yml` file itself.
2022-05-17 14:03:58 +01:00
Alex Waygood
e9526faf40
Various py311 removals ( #7836 )
2022-05-16 17:28:13 -07: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
Alex Waygood
fed1f35c32
Remove explicit inheritance from object ( #7819 )
2022-05-10 16:24:53 +03:00
Alex Waygood
ac30b96d14
Use str instead of Text ( #7812 )
2022-05-09 20:47:11 +01: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
4e946b74bf
csv.pyi: minor cleanup (#7790 )
2022-05-07 10:49:27 +02:00
Alex Waygood
5c6178a821
Import generics from standard modules in all third-party stubs ( #7791 )
2022-05-07 10:35:50 +02:00
Alex Waygood
16ca92fac7
Add http.HTTPMethod ( #7784 )
...
https://github.com/python/cpython/pull/91997
`description` isn't actually read-only at runtime, but I don't think there's any other way of telling type checkers "this is an attribute that the members have, not a member itself". And pretending it's a property is already what we do for `HTTPStatus`, which has the same issue.
2022-05-06 23:48:52 -07:00
Alex Waygood
5f557176b4
_csv.pyi: minor cleanup (#7789 )
2022-05-06 11:38:19 -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
Alex Waygood
c3ebc7e307
More improvements to pow stubs ( #7737 )
2022-04-28 10:49:29 -06:00
Alex Waygood
59c346d031
cryptography: make oid attributes readonly ( #7731 )
2022-04-28 00:58:49 -06:00
Alex Waygood
a95a862ca8
Upgrade to pytype 2022.4.26 ( #7699 )
2022-04-26 15:40:47 -06:00
Alex Waygood
7cbb579a44
Make __wrapped__ read-only on classmethods and staticmethods ( #7694 )
2022-04-25 22:27:06 -06:00
Alex Waygood
2773480d13
Add regression tests for builtins.pow and object.__reduce__ ( #7663 )
2022-04-21 21:17:37 -07:00
Alex Waygood
a8504f269e
Use _typeshed.OptExcInfo in pydoc and unittest ( #7668 )
2022-04-20 21:00:48 +01:00
Alex Waygood
b093c90a94
Use TypeAlias for type aliases where possible, part II ( #7667 )
2022-04-20 20:02:47 +01:00
Alex Waygood
c653be73b8
Use TypeAlias for argparse type aliases ( #7664 )
2022-04-20 07:32:10 -07:00
Alex Waygood
85594df83b
Use re-exports instead of TypeAliases in email.parser ( #7665 )
2022-04-20 07:31:52 -07:00
Alex Waygood
197dac2c0c
Upgrade flake8-pyi to 22.4.1 ( #7662 )
2022-04-18 22:52:44 +01:00
Alex Waygood
3930d8d12a
Make several type aliases private ( #7661 )
2022-04-18 22:19:16 +01:00
Alex Waygood
617d2aaf57
Fix crash when running mypy master against typeshed master ( #7660 )
2022-04-18 17:20:49 +01:00
Alex Waygood
eafc23ddb8
Add one more # noqa to unblock https://github.com/PyCQA/flake8-pyi/pull/213 ( #7659 )
...
Missed one.
2022-04-18 09:09:40 -07:00
Alex Waygood
54af68c789
Add a few # noqas to unblock PyCQA/flake8-pyi#213 ( #7658 )
2022-04-18 17:57:48 +02:00
Alex Waygood
073f9f416d
Use PEP 585 syntax in collections ( #7657 )
2022-04-18 15:33:50 +01:00
Alex Waygood
97a74bc1aa
Import from collections.abc wherever possible ( #7635 )
2022-04-18 12:50:37 +02:00
Alex Waygood
7ce4607dee
Upgrade flake8-pyi to 22.4.0, enable Y026 in .flake8 config ( #7650 )
2022-04-17 01:23:35 +01:00
Alex Waygood
2e98c8284c
Move code from decimal.pyi to _decimal.pyi ( #7640 )
...
* Move code from `decimal.pyi` to `_decimal.pyi`
The stub previously did `from decimal import *` in `_decimal.pyi`, but the opposite happens at runtime.
2022-04-16 17:01:13 +01:00
Alex Waygood
819900fa55
Python 3 stubs: use str instead of typing.Text ( #7638 )
2022-04-16 15:47:00 +01:00
Alex Waygood
653f2c6ba4
Third-party stubs: import from collections.abc where possible ( #7637 )
2022-04-16 14:52:57 +01:00
Alex Waygood
66bea8ca48
Use imports instead of TypeAliases in a couple places ( #7634 )
...
Fixes #7632
2022-04-16 01:38:59 -07:00
Alex Waygood
740193a8fc
Use TypeAlias where possible for type aliases ( #7630 )
2022-04-15 18:01:00 -07:00
Alex Waygood
c0e6dd3f3f
Use str instead of typing.Text ( #7629 )
2022-04-16 00:47:42 +02:00
Alex Waygood
40985b4f02
Fix various __all__ bugs and omissions ( #7618 )
2022-04-14 08:03:19 -07: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
Alex Waygood
536f783a82
Exclude Y037 in .flake8 config, for now ( #7600 )
...
Unblocks https://github.com/PyCQA/flake8-pyi/pull/202
2022-04-06 17:24:02 +01:00
Alex Waygood
3c85f36b7f
Reduce code duplication in the email module ( #7558 )
2022-04-06 12:20:14 +02:00
Alex Waygood
1ceb486b75
Replace Union with union operator ( #7596 )
2022-04-05 23:07:31 +02:00
Alex Waygood
85aec034ae
Mark many attributes as read-only properties ( #7591 )
2022-04-05 08:37:24 +02:00
Alex Waygood
b8f2eb3930
Make several fields on _dummy_threading classes read-only properties ( #7588 )
2022-04-05 08:35:00 +02:00
Alex Waygood
414f324083
Add missing __match_args__ attributes to several unix-only structseq classes ( #7587 )
2022-04-04 21:33:49 +01:00
Alex Waygood
be64b01e6c
Upgrade black version ( #7582 )
2022-04-03 22:34:44 +01:00
Alex Waygood
646993c211
Improve imp._FileLike.__exit__ ( #7577 )
...
The signature of this method currently doesn't work quite as intended: see https://github.com/PyCQA/flake8-pyi/pull/199#issuecomment-1086087342
Classes will [still be accepted](https://mypy-play.net/?mypy=latest&python=3.10&gist=77efe095d01edeb1a4614166f0c9cf68 ) as conforming to this protocol if they have more permissive signatures such as `def __exit__(self, *args: object) -> None: ...`
2022-04-01 18:01:23 +01:00
Alex Waygood
ec27c00ca2
Third-party stubs: Improve several __exit__ methods ( #7575 )
2022-04-01 08:03:12 -07:00
Alex Waygood
ae6ff79c0e
flake8 config: remove line that exists only for Python-2 checking ( #7570 )
2022-04-01 08:07:16 +02:00
Alex Waygood
da3e69d093
stdlib: Improve a bunch of __(a)exit__ methods ( #7571 )
2022-04-01 08:05:25 +02:00
Alex Waygood
85f060b26d
Exclude the Python-2 stdlib from flake8 CI check ( #7569 )
...
We should hopefully be getting rid of this entire subdirectory soon anyway (#7367 ). This will make PRs to flake8-pyi a lot easier.
2022-03-31 23:35:45 +01:00
Alex Waygood
1245bbcc8d
Use type alias to simplify overloads in unittest.mock ( #7563 )
2022-03-29 08:19:26 +02:00
Alex Waygood
a3245db63c
Remove unneeded # noqa comments, fix broken # noqa comments ( #7561 )
2022-03-28 23:17:44 +02: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
Alex Waygood and Jelle Zijlstra
61b22db692
Add many missing __match_args__ attributes ( #7556 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com >
2022-03-26 19:36:28 +00:00
Alex Waygood
1192db784c
Use flake8-pyi 22.3.0 ( #7557 )
...
Hot off the presses!
2022-03-26 19:27:11 +00:00
Alex Waygood
b63c963077
Use conditional overloads to simplify several stdlib functions ( #7540 )
2022-03-25 08:47:03 +01:00
Alex Waygood
d086488e0e
Revert "Use import instead of type alias in email/message.pyi" ( #7548 )
...
Let's see if this is fixed in mypy 0.942.
This reverts the changes made in #7022 , which was a hack to fix #7019
2022-03-24 11:22:30 -07:00
Alex Waygood
4b63f345ad
Upgrade mypy version to 0.942 ( #7547 )
2022-03-24 18:42:26 +01:00
Alex Waygood
74ecce5b68
Improve host parameter of socket.getaddrinfo() ( #7518 )
...
As pointed out by @srittau in #7517 , `bytearray` [is redundant](https://docs.python.org/3/library/typing.html#typing.ByteString ) in a union where `bytes` is also in the union.
2022-03-20 23:35:03 +00:00
Alex Waygood and Jelle Zijlstra
1acc8f3bd6
Use PEP 604 syntax wherever possible, part II ( #7514 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com >
2022-03-19 14:27:35 +00:00
Alex Waygood and Jelle Zijlstra
340c6c97ed
Add mypy error codes to type: ignores, remove unused ignores ( #7504 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com >
2022-03-19 13:10:00 +00:00
Alex Waygood
4308915e06
Make __hash__ a ClassVar for several classes where it is set to None ( #7485 )
2022-03-19 05:59:10 -07:00
Alex Waygood and Thomas Grainger
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
e8286e7048
Use PEP 604 syntax in non-autogenerated protobuf stubs ( #7506 )
2022-03-17 11:34:31 +00:00
Alex Waygood
ec8f51726f
Unpin pyright-action ( #7499 )
...
The issues that broke typeshed's CI have been fixed by https://github.com/jakebailey/pyright-action/commit/e7c2cbabca407c6ba1eecc5c2317422f8a609c2a
2022-03-16 16:21:05 +00:00
Alex Waygood
3ab250eec8
Use PEP 604 syntax wherever possible ( #7493 )
2022-03-16 16:01:33 +01:00
Alex Waygood and Jelle Zijlstra
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
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
Alex Waygood
8134752ad8
requests stubs are not Python 2-compatible (#7483 )
2022-03-13 13:06:34 +01:00
Alex Waygood
d3df6da103
parsimonious: re.Match does not exist in Python 3.6 ( #7482 )
...
It has to be imported from `typing` in <3.7.
Refs https://github.com/python/typeshed/pull/7478 .
2022-03-13 00:23:31 -08:00
Alex Waygood
9a1f5fb06c
Modernize syntax in various stubs ( #7469 )
...
Use `str` and `contextlib.AbstractContextManager` instead of `typing.Text` and `typing.ContextManager`.
2022-03-09 21:23:26 +00:00
Alex Waygood
4e87b9058f
Improve collections.Counter stub ( #7464 )
2022-03-09 12:22:28 +02:00
Alex Waygood
db6f912c77
Improve mmap.mmap.__enter__ ( #7461 )
...
It returns `Self` at runtime, not `mmap.mmap`, so inheriting from `AbstractContextManager` doesn't really do anything for us.
2022-03-08 07:47:56 -08:00
Alex Waygood
f4ae363b56
stdlib: correct many pos-or-kw arg names in dunder methods ( #7451 )
2022-03-07 16:40:03 +01:00
Alex Waygood
626ccdaee2
Add @AlexWaygood as a maintainer ( #7450 )
2022-03-07 15:08:19 +00:00
Alex Waygood
947724a5cb
stdlib: Add several missing @abstractmethod decorators ( #7443 )
2022-03-06 16:41:13 -08:00
Alex Waygood
1a2f718ceb
Make several fields read-only for type, staticmethod and classmethod ( #7423 )
2022-03-06 15:50:26 -08:00
Alex Waygood
ea6e06a60d
Use bound methods in pydoc ( #7426 )
2022-03-06 15:49:15 -08:00
Alex Waygood
bc72b25a2a
Make more miscellaneous fields read-only, annotate _json.make_encoder ( #7439 )
2022-03-06 15:41:49 -08:00