summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-108303: Move more `typing` related files to `Lib/test/typinganndata` ↵Nikita Sobolev2023-11-081-2/+1
| | | | | (#111825) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-111808: Fix recursion error on WASM in `test_typing` (GH-111819)Nikita Sobolev2023-11-071-5/+6
|
* gh-111681: minor fixes to typing doctests; remove unused imports in ↵Nikita Sobolev2023-11-031-3/+2
| | | | | `test_typing` (#111682) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-111126: Use `isinstance` instead of `assert[Not]IsInstance` in ↵Nikita Sobolev2023-10-201-4/+4
| | | | `test_typing` (#111127)
* gh-110782: Fix crash when TypeVar is constructed with keyword args (#110784)Jelle Zijlstra2023-10-121-0/+6
|
* gh-110682: Ignore `__match_args__` from `__instancecheck__` in protocols ↵Nikita Sobolev2023-10-121-0/+33
| | | | | (#110683) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* Enable ruff on `Lib/test/test_typing.py` (#110179)Alex Waygood2023-10-021-52/+52
|
* gh-110178: Use fewer weakrefs in test_typing.py (#110194)Jelle Zijlstra2023-10-021-1/+1
| | | Confirmed that without the C changes from #108517, this test still segfaults with only 10 weakrefs.
* gh-109653: `typing.py`: improve import time by creating soft-deprecated ↵Alex Waygood2023-09-231-0/+4
| | | | | members on demand (#109651) Co-authored-by: Thomas Grainger <tagrain@gmail.com>
* gh-109543: Remove unnecessary hasattr check (#109544)Jelle Zijlstra2023-09-201-0/+11
| | | | Also added a new test case covering the scenario I thought this might be about.
* gh-105509: Simplify implementation of `typing.Annotated` (#105510)Alex Waygood2023-09-011-2/+1
|
* gh-108295: Fix crashes with TypeVar weakrefs (#108517)Jelle Zijlstra2023-08-271-0/+10
|
* gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354)Nikita Sobolev2023-08-231-2/+4
|
* gh-101162: Forbid using issubclass() with GenericAlias as the 1st arg ↵Nikita Sobolev2023-08-111-0/+16
| | | | (GH-103369)
* gh-106309: Deprecate typing.no_type_check_decorator (#106312)Alex Waygood2023-07-131-4/+8
|
* gh-105974: Revert unintentional behaviour change for protocols with ↵Alex Waygood2023-06-231-0/+40
| | | | non-callable members and custom `__subclasshook__` methods (#105976)
* gh-105834: Add tests for calling `issubclass()` between two protocols (#105835)Alex Waygood2023-06-161-0/+74
| | | Some parts of the implementation of `typing.Protocol` had poor test coverage
* gh-105570: Deprecate unusual ways of creating empty TypedDicts (#105780)Alex Waygood2023-06-141-0/+34
| | | Deprecate two methods of creating typing.TypedDict classes with 0 fields using the functional syntax: `TD = TypedDict("TD")` and `TD = TypedDict("TD", None)`. Both will be disallowed in Python 3.15. To create a TypedDict class with 0 fields, either use `class TD(TypedDict): pass` or `TD = TypedDict("TD", {})`.
* gh-105566: Deprecate unusual ways of creating `typing.NamedTuple` classes ↵Alex Waygood2023-06-141-9/+74
| | | | | | | (#105609) Deprecate creating a typing.NamedTuple class using keyword arguments to denote the fields (`NT = NamedTuple("NT", x=int, y=str)`). This will be disallowed in Python 3.15. Use the class-based syntax or the functional syntax instead. Two methods of creating `NamedTuple` classes with 0 fields using the functional syntax are also deprecated, and will be disallowed in Python 3.15: `NT = NamedTuple("NT")` and `NT = NamedTuple("NT", None)`. To create a `NamedTuple` class with 0 fields, either use `class NT(NamedTuple): pass` or `NT = NamedTuple("NT", [])`.
* gh-104873: Add typing.get_protocol_members and typing.is_protocol (#104878)Jelle Zijlstra2023-06-141-2/+67
| | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-105431: Remove unused stuff from `test_typing.NewTypeTests` (#105432)Nikita Sobolev2023-06-081-7/+0
|
* gh-103171: Forward-port new tests for runtime-checkable protocols dec orated ↵Alex Waygood2023-06-071-0/+65
| | | | | with `@final` (#105473) Forward-port of the tests that were added to the 3.11 branch in #105445
* gh-105280: Ensure `isinstance([], collections.abc.Mapping)` always evaluates ↵Alex Waygood2023-06-051-0/+14
| | | | to `False` (#105281)
* gh-105237: Allow calling `issubclass(X, typing.Protocol)` again (#105239)Alex Waygood2023-06-051-0/+59
|
* gh-105144: Runtime-checkable protocols: move all 'sanity checks' to ↵Alex Waygood2023-05-311-18/+91
| | | | `_ProtocolMeta.__subclasscheck__` (#105152)
* Remove raw asserts in test_typing.py (#104951)Jelle Zijlstra2023-05-261-22/+30
|
* gh-104786: Remove kwargs-based TypedDict creation (#104891)Tomas R2023-05-251-30/+3
| | | | | Deprecated since Python 3.11. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-104935: typing: Fix interactions between `@runtime_checkable` and ↵Jelle Zijlstra2023-05-251-0/+42
| | | | | | | `Generic` (#104939) --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-104879: Fix TypeAliasType.__module__ in exec() (#104881)Jelle Zijlstra2023-05-241-0/+34
|
* Improve test coverage for is_typeddict (#104884)Jelle Zijlstra2023-05-241-3/+22
| | | | | In particular, it's important to test that is_typeddict(TypedDict) returns False.
* gh-104797: Allow Protocols to inherit from collections.abc.Buffer (#104827)Jelle Zijlstra2023-05-241-0/+16
|
* gh-92871: Remove typing.{io,re} namespaces (#92873)Sebastian Rittau2023-05-231-23/+1
| | | | | | Closes #92871 Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-74690: Make a typing test more resilient (#104691)Alex Waygood2023-05-211-4/+3
|
* gh-104600: Make type.__type_params__ writable (#104634)Jelle Zijlstra2023-05-191-0/+27
| | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-74690: Don't set special protocol attributes on non-protocol subclasses ↵Alex Waygood2023-05-181-0/+15
| | | | | of protocols (#104622) Don't set special protocol attributes on non-protocol subclasses of protocols
* gh-104555: Runtime-checkable protocols: Don't let previous calls to ↵Alex Waygood2023-05-171-0/+76
| | | | | `isinstance()` influence whether `issubclass()` raises an exception (#104559) Co-authored-by: Carl Meyer <carl@oddbird.net>
* typing: Add more tests for TypeVar (#104571)Jelle Zijlstra2023-05-171-0/+42
| | | | | | | | During the PEP 695 implementation at one point I made TypeVar.__name__ return garbage, and all of test_typing passed. So I decided to add a few more tests. In the process I discovered a minor incompatibility from the C implementation of TypeVar: empty constraints were returned as None instead of an empty tuple.
* gh-104555: Fix isinstance() and issubclass() for runtime-checkable protocols ↵Alex Waygood2023-05-161-0/+18
| | | | | that use PEP 695 (#104556) Fixes #104555
* gh-103763: Implement PEP 695 (#103764)Jelle Zijlstra2023-05-161-35/+19
| | | | | | | | | | | | | | This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-91896: Revert some very noisy DeprecationWarnings for `ByteString` (#104424)Alex Waygood2023-05-131-22/+6
|
* gh-91896: Improve visibility of `ByteString` deprecation warnings (#104294)Alex Waygood2023-05-121-4/+26
|
* GH-103629: Update Unpack's repr in compliance with PEP 692 (#104048)Franek Magiera2023-05-011-27/+32
|
* gh-104036: Fix direct invocation of test_typing (#104037)Kirill Podoprigora2023-05-011-1/+1
| | | Previously, `python -m test test_typing` worked, but `python Lib/test/test_typing.py` did not.
* gh-103746: Test `types.UnionType` and `Literal` types together (#103747)Nikita Sobolev2023-04-241-0/+5
|
* gh-103592: Add tests of `Literal` with `Enum` and `Union` of `Literal`s ↵Nikita Sobolev2023-04-231-0/+45
| | | | (#103706)
* GH-103699: Add `__orig_bases__` to various typing classes (#103698)Adrian Garcia Badaracco2023-04-231-0/+59
| | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-103395: Improve `typing._GenericAlias.__dir__` coverage (#103396)Nikita Sobolev2023-04-101-2/+61
|
* gh-74690: Add more tests for runtime-checkable protocols (#103347)Alex Waygood2023-04-071-2/+39
|
* gh-102433: Use `inspect.getattr_static` in ↵Alex Waygood2023-04-021-2/+91
| | | | `typing._ProtocolMeta.__instancecheck__` (#103034)
* gh-103054: typing: Improve `Callable` type substitution tests (#103055)Nikita Sobolev2023-03-291-0/+42
| | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>