Commit Graph

33 Commits

Author SHA1 Message Date
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
Sebastian Rittau
2f3964e24b Return ItemsView/KeysView from Mapping methods (#6014)
* Return ItemsView/KeysView from Mapping methods

* Make RawConfigParser compatible with Mapping
2021-09-09 07:37:26 -07:00
Torsten Wörtwein
d4f0725452 BUG: typing.final supports properties (#5985)
Fixes #5984
2021-08-31 09:07:57 +02:00
Anton Grübel
ac2ef6e8c9 Use paramspec in no_type_check_decorator (#5942) 2021-08-26 22:46:27 +03:00
Oleg Höfling
64f481189f drop ellipsis assignments from module vars, classvars and instance attrs (#5914)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-08-11 19:26:58 +02:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Sebastian Rittau
840df19501 Switch to Python 3.10.0-rc.1 in CI (#5845)
* Switch to Python 3.10.0-rc.1 in CI

* Add module argument to ForwardRef.__init__()
2021-08-04 07:14:38 -07:00
Jelle Zijlstra
e1b9ab3372 Remove redundant import from typing (#5827)
Fixes quora/pyanalyze#221.
2021-07-30 22:55:33 -07:00
Sebastian Rittau
52dd232a23 Rework Match.group handling (#5557)
* Rework Match.group handling

Standardize group(), groups(), groupdict(), and __getattr__() to return
Any instead of AnyStr. Also special case group(0) and __getattr__(0) to
always return AnyStr. Use PEP 604 for unions in changed lines.
2021-06-09 00:27:49 +03:00
Terence Honles
63696823d7 typing: type decorators so they don't count as untyped lines (#5348) 2021-05-06 15:57:52 -07:00
Shantanu
59bf496479 typing: ParamSpec uses kw-only args (#5310)
Co-authored-by: hauntsaninja <>
2021-05-02 12:52:13 -07:00
Shantanu
3aa1f2d42f typing: update and fix for py310 (#5287) 2021-05-01 21:09:26 -07:00
Sebastian Rittau
4ac3ccad45 black: enable skip_magic_trailing_comma (#5252)
* black: enable skip_magic_trailing_comma

* Remove spurious commas
2021-04-27 08:32:32 -07:00
Jelle Zijlstra
97c6806582 Revert "Awaitable.__await__ should accept an Iterator rather than a Generator (#5194)" (#5195)
This reverts commit c687e297ec.
2021-04-09 09:49:39 +02:00
Wilfredo Sánchez Vega
c687e297ec Awaitable.__await__ should accept an Iterator rather than a Generator (#5194)
Fixes #5125
2021-04-09 01:43:46 +02:00
Eric Traut
e2967a8bee Eliminated the use of "bare" TypeVars in stdlib stubs (#5041)
Eliminated the use of "bare" TypeVars (i.e. a TypeVar that appears only once) within generic methods. While not considered an error in PEP 484, these are a common source of bugs in code, and some type checkers (including pytype and pyright) flag them as errors.

Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-02-27 19:43:45 -08:00
Eric Traut
ffcd592aef Added support for | operator for combining two TypedDict instances (#5054)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-02-23 10:04:31 +01:00
Ivan Levkivskyi
16ae4c6120 Re-organize directory structure (#4971)
See discussion in #2491

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
2021-01-27 12:00:39 +00:00