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
947724a5cb
stdlib: Add several missing @abstractmethod decorators ( #7443 )
2022-03-06 16:41:13 -08:00
Alex Waygood
bc72b25a2a
Make more miscellaneous fields read-only, annotate _json.make_encoder ( #7439 )
2022-03-06 15:41:49 -08:00
Alex Waygood
3bbc36c92d
Add two missing ForwardRef attributes ( #7402 )
...
These look somewhat like implementation details, but no more so than any of the other dunder attributes that are already on the class.
2022-02-28 21:44:28 -08:00
Alex Waygood
6a743348ca
Add __all__ for most modules beginning with 't' ( #7373 )
2022-02-23 18:25:28 -08:00
Shantanu
0eb6baa663
typing: don't accidentally use typing.Self ( #7318 )
...
We can switch to it when all type checkers have support
Co-authored-by: hauntsaninja <>
2022-02-19 19:53:30 -08:00
Alex Waygood
1091521f60
stdlib: Add several missing __(deep)copy__ methods ( #7242 )
2022-02-16 18:57:41 -08:00
Alex Waygood
5e8a2a9364
Fix various pos-only stubtest complaints previously allowlisted ( #7228 )
2022-02-15 17:51:34 +01:00
Shantanu
a6d9b83263
Add @final to several more stdlib classes ( #7215 )
...
Co-authored-by: hauntsaninja <>
2022-02-14 15:12:40 -08:00
Jelle Zijlstra
7dd2485269
New additions to typing, typing_extensions ( #7169 )
2022-02-08 22:40:09 -08:00
Joshua Bronson
9a257c18bb
Add missing type hint for AbstractSet._hash(). ( #7153 )
2022-02-08 06:18:52 -08:00
Alex Waygood
398a5807a1
Return Self from MutableSequence.__iadd__ ( #7162 )
2022-02-08 06:15:37 -08:00
Alex Waygood
b1b3471c76
Improve in-place BinOp methods for sets ( #7161 )
2022-02-08 14:57:50 +01:00
Alex Waygood
584336a41e
Fix several methods that should be async def, but aren't ( #7107 )
2022-02-02 15:18:14 +01:00
Nikita Sobolev
970b8a676c
Use async def instead of def ... -> Awaitable in typing ( #7105 )
2022-02-02 13:14:08 +01:00
Shantanu
b88a6f19cd
Upgrade black version ( #7089 )
2022-01-30 16:27:06 -08:00
Alex Waygood
45a2dad83c
Reduce use of Any in equality methods ( #7081 )
...
Co-authored-by: Akuli <akuviljanen17@gmail.com >
2022-01-30 00:59:00 +02:00
Alex Waygood
99cec2d16b
Reduce duplication of code between typing and typing_extensions ( #7075 )
2022-01-29 07:44:42 -08:00
Alex Waygood
7e79706ddd
Clarify why some module-level objects in typing have default values ( #7037 )
2022-01-28 17:38:25 -08:00
Sebastian Rittau
b87ebc5375
Don't use a literal for TYPE_CHECKING ( #7062 )
...
Partly addresses #7061
2022-01-27 23:51:22 -08:00
Alex Waygood
dbb5488b31
Do not use True or False as default values in assignments ( #7060 )
2022-01-27 13:51:36 -08:00
Alex Waygood
5d07ebc864
Use PEP 585 syntax in typing and typing_extensions, and remove module-level defaults where possible ( #7036 )
2022-01-25 16:13:36 +01:00
Akuli
a22ca2ec51
make the default positional-or-keyword in Mapping.get and MutableMapping.pop ( #6694 )
2022-01-22 07:19:01 -08:00
Jelle Zijlstra
1f000d2881
Improve type for setdefault() ( #6941 )
...
- With one argument, it may return None
- With two arguments, it returns the default's type or the dict's value type.
- Also remove incorrect `= ...` from `pop()`. The one-argument case has its own overload.
Context: https://github.com/python/typing/discussions/1033#discussioncomment-1986359
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com >
2022-01-19 21:44:15 -08:00
Alex Waygood
2170693e11
Add various __*or__ methods, and improve dict.__ior__ ( #6961 )
2022-01-19 12:24:16 +01:00
Jelle Zijlstra
ea93779c92
Fix TypeVar argument annotations ( #6943 )
...
Arguments like bound= accept type forms like unions, which are not themselves types.
2022-01-18 00:14:40 -08:00
Alex Waygood
af8e37d273
Add # noqa comments to typing.AnyStr ( #6925 )
...
Co-authored-by: Akuli <akuviljanen17@gmail.com >
2022-01-16 14:23:22 +02:00
Alex Waygood
96c9abb058
Always use _typeshed.Self, where applicable ( #6880 )
...
* Always use `_typeshed.Self`, where applicable
* Revert changes to `google-cloud-ndb` (ambiguous)
* Remove empty line added by script
* Revert changes to `stubs/python-dateutil/dateutil/relativedelta.pyi`
* Manually add a few more that the script missed
* Improve `filelock` annotation
Source code here: 79ec7b2826/src/filelock/_api.py (L207)
* Improve `opentracing/scope` annotation
Source code here: 3e1d357a34/opentracing/scope.py (L71)
* Improve `redis/client` stub
Source code here: 15f315a496/redis/client.py (L1217)
* Improve `redis/lock` annotation
Source code here: 15f315a496/redis/lock.py (L155)
* Improve `requests/models` annotation
Source code here: d718e75383/requests/models.py (L653)
2022-01-09 19:16:19 -08:00
Alex Waygood
4e046163b5
Delete many redundant method redefinitions ( #6877 )
2022-01-09 11:21:03 -08:00
Sebastian Rittau
f4ce1ebaf8
Use positional-only arguments for IO ( #6851 )
2022-01-08 20:49:29 +02:00
Joseph Young
d43cd997a4
re.Match.lastgroup is str rather than AnyStr ( #6776 )
2022-01-01 15:14:23 +02:00
Akuli
38a08fcf04
List returned from re.split() can contain Nones ( #6763 )
2021-12-30 13:27:39 -06:00
Andrew
ff6d084995
Fix NamedTuple._field_types for python > 3.9 ( #6728 )
...
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com >
Co-authored-by: Akuli <akuviljanen17@gmail.com >
2021-12-29 18:58:42 +02:00
Jelle Zijlstra
14268f64e5
Widen MutableMapping.update type ( #6653 )
2021-12-22 08:54:05 +01:00
Sebastian Rittau
c900c0e769
Fix Python 3.10.1 problems pointed out by stubtest ( #6604 )
...
Co-authored-by: Akuli <akuviljanen17@gmail.com >
2021-12-16 07:05:45 -08:00
Jelle Zijlstra
7d4d58925a
typing: update comments ( #6558 )
2021-12-09 21:15:27 -08:00
Alex Waygood
ff4bd7c465
Add __(r)or__ to various typing classes ( #6498 )
...
- `__or__` was added to `TypeVar` in Python 3.10: https://bugs.python.org/issue41428 (this PR: https://github.com/python/cpython/pull/21515 )
- `__or__` was added to `ForwardRef` in Python 3.11: https://bugs.python.org/issue45489
2021-12-05 15:16:19 -08:00
Alex Waygood
050a77d8e3
Make NewType a class in 3.10 ( #6469 )
2021-12-03 13:33:44 +01:00
Shantanu
e734231314
typing: add _ProtocolMeta ( #6394 )
...
Co-authored-by: hauntsaninja <>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-27 16:53:36 +02:00
Akuli
a5bc1e037f
Add mypy error codes to '# type: ignore' comments ( #6379 )
2021-11-26 07:07:56 +01:00
Alex Waygood
5c8e68f0eb
Use lowercase set, frozenset and deque where possible ( #6346 )
2021-11-19 15:05:45 -08:00
Jelle Zijlstra
0d7064c357
Make Mapping/MutableMapping params positional-only ( #5772 )
...
These are positional-only on dict, so it makes sense to mark them as positional-only in these base classes too.
Fixes #5771
2021-11-18 07:54:58 +01:00
Alex Waygood
10c9d8cfce
Add @final to many unsubclassable stdlib classes ( #6299 )
2021-11-15 14:45:24 +01:00
Jelle Zijlstra
9eabedca5f
Make NoReturn a SpecialForm ( #6290 )
...
This is consistent with the runtime definition: https://github.com/python/cpython/blob/main/Lib/typing.py#L434 .
The previous definition was wrong; NoReturn is not and should not be equivalent to None. This fixes an issue in pyanalyze where it was interpreting NoReturn as equivalent to None.
2021-11-12 17:34:44 -08:00
Alex Waygood
d5d0ba158e
Make `__round__ positional-only for float, int, Decimal and SupportsRound` ( #6242 )
2021-11-07 15:05:18 -08:00
Sebastian Rittau
b3f29b619b
Remove unnecessary _Collection alias ( #6188 )
...
This was a remnant of Python 3.5 compatibility, where Collection did not
exists and _Collection was aliased to a dummy class.
2021-10-22 12:32:35 -07:00
Akuli
994b69ef8f
Use lowercase tuple where possible ( #6170 )
2021-10-14 17:18:19 -07:00
Jelle Zijlstra
5f386b0575
Make args to AsyncContextManager.__aexit__ positional-only ( #6172 )
...
We already do this for `ContextManager.__exit__`. Should fix microsoft/pyright#2435 .
2021-10-14 17:15:57 -07:00
Nikita Sobolev
4ac969ad2c
Fixes __init__ of typing.NamedTuple ( #6080 )
...
Closes #6079
2021-09-28 20:42:27 -07:00
Sebastian Rittau
9295c70ec0
'module' argument to ForwardRef.__init__() added in Python 3.9.7 ( #6017 )
...
Pin Python 3.9.7 for stubtest and update 3.10.0 to rc2
2021-09-10 01:10:28 +02:00