Nikita Sobolev
992c3f6b51
[3.12] gh-108303: Move more typing related files to Lib/test/typinganndata (GH-111825) ( #111859 )
...
[3.12] gh-108303: Move more typing related files to Lib/test/typinganndata(GH-111825)
2023-11-08 16:56:24 +00:00
Miss Islington (bot)
4a1026077a
[3.12] gh-111126: Use isinstance
instead of assert[Not]IsInstance
in test_typing
(GH-111127) ( #111130 )
...
gh-111126: Use `isinstance` instead of `assert[Not]IsInstance` in `test_typing` (GH-111127)
(cherry picked from commit ea7c26e4b8
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-20 18:27:35 +00:00
Miss Islington (bot)
27d5ea291c
[3.12] gh-110782: Fix crash when TypeVar is constructed with keyword args (GH-110784) ( #110787 )
...
gh-110782: Fix crash when TypeVar is constructed with keyword args (GH-110784)
(cherry picked from commit d2a536b170
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-12 23:24:37 +00:00
Alex Waygood
4dac406f66
[3.12] Enable ruff on Lib/test/test_typing.py
( #110179 ) ( #110288 )
...
Enable ruff on `Lib/test/test_typing.py` (#110179 )
2023-10-03 15:13:22 +00:00
Miss Islington (bot)
46e69576a9
[3.12] gh-110178: Use fewer weakrefs in test_typing.py (GH-110194) ( #110224 )
...
gh-110178: Use fewer weakrefs in test_typing.py (GH-110194)
Confirmed that without the C changes from GH-108517, this test still segfaults with only 10 weakrefs.
(cherry picked from commit 732ad44cec
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-02 18:15:30 +01:00
Miss Islington (bot)
b153cab6d8
[3.12] gh-108303: Move ann_module*.py
files to typinganndata/
folder (GH-108354) ( #109672 )
...
gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (GH-108354)
(cherry picked from commit 3f61cf646d
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-02 17:10:33 +02:00
Miss Islington (bot)
09877a15d5
[3.12] gh-108295: Fix crashes with TypeVar weakrefs (GH-108517) ( #108527 )
...
gh-108295: Fix crashes with TypeVar weakrefs (GH-108517)
(cherry picked from commit 482fad7f01
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-08-27 16:12:57 +02:00
Miss Islington (bot)
7d6ee298e9
[3.12] gh-105974: Revert unintentional behaviour change for protocols with non-callable members and custom __subclasshook__
methods (GH-105976) ( #106032 )
...
gh-105974: Revert unintentional behaviour change for protocols with non-callable members and custom `__subclasshook__` methods (GH-105976)
(cherry picked from commit 9499b0f138
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-23 15:26:37 +00:00
Miss Islington (bot)
e6982c5860
[3.12] gh-105834: Add tests for calling issubclass()
between two protocols (GH-105835) ( #105859 )
...
Some parts of the implementation of `typing.Protocol` had poor test coverage
(cherry picked from commit 70c075c194
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-16 16:20:19 +00:00
Miss Islington (bot)
2b6f475db8
[3.12] gh-105431: Remove unused stuff from test_typing.NewTypeTests
(GH-105432) ( #105489 )
...
gh-105431: Remove unused stuff from `test_typing.NewTypeTests` (GH-105432)
(cherry picked from commit 9d35a71a76
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-06-08 06:57:21 +00:00
Miss Islington (bot)
4b2263e4bf
[3.12] gh-103171: Forward-port new tests for runtime-checkable protocols decorated with @final
(GH-105473) ( #105474 )
...
Forward-port of the tests that were added to the 3.11 branch in GH-105445
(cherry picked from commit f5df347fcf
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-07 22:54:42 +00:00
Miss Islington (bot)
2031238eb6
[3.12] gh-105280: Ensure isinstance([], collections.abc.Mapping)
always evaluates to False
(GH-105281) ( #105318 )
...
gh-105280: Ensure `isinstance([], collections.abc.Mapping)` always evaluates to `False` (GH-105281)
(cherry picked from commit 08756dbba6
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-05 14:51:26 +00:00
Miss Islington (bot)
51750269cf
[3.12] gh-105237: Allow calling issubclass(X, typing.Protocol)
again (GH-105239) ( #105316 )
...
gh-105237: Allow calling `issubclass(X, typing.Protocol)` again (GH-105239)
(cherry picked from commit cdfb201bfa
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-05 14:06:25 +00:00
Miss Islington (bot)
076f3cda14
[3.12] gh-105144: Runtime-checkable protocols: move all 'sanity checks' to _ProtocolMeta.__subclasscheck__
(GH-105152) ( #105160 )
...
(cherry picked from commit c05c31db8c
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-31 17:35:03 +00:00
Miss Islington (bot)
01af2b0e51
[3.12] Remove raw asserts in test_typing.py (GH-104951) ( #104978 )
...
Remove raw asserts in test_typing.py (GH-104951)
(cherry picked from commit 2cb445635e
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-26 14:35:35 +00:00
Miss Islington (bot)
930efde4c7
[3.12] gh-104935: typing: Fix interactions between @runtime_checkable
and Generic
(GH-104939) ( #104941 )
...
gh-104935: typing: Fix interactions between `@runtime_checkable` and `Generic` (GH-104939)
---------
(cherry picked from commit 2b7027d0b2
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-25 17:15:48 +00:00
Miss Islington (bot)
b670214636
[3.12] gh-104879: Fix TypeAliasType.__module__ in exec() (GH-104881) ( #104890 )
...
(cherry picked from commit fe77a99fc8
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-24 19:30:57 +00:00
Miss Islington (bot)
3d91d034a0
[3.12] Improve test coverage for is_typeddict (GH-104884) ( #104889 )
...
Improve test coverage for is_typeddict (GH-104884)
In particular, it's important to test that is_typeddict(TypedDict)
returns False.
(cherry picked from commit 1497607a8e
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-24 19:21:28 +00:00
Miss Islington (bot)
d10d1e3b10
[3.12] gh-104797: Allow Protocols to inherit from collections.abc.Buffer (GH-104827) ( #104841 )
...
gh-104797: Allow Protocols to inherit from collections.abc.Buffer (GH-104827)
(cherry picked from commit c0ab7d401c
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-24 09:05:34 +00:00
Alex Waygood
b870b1fa75
gh-74690: Make a typing test more resilient ( #104691 )
2023-05-20 17:13:37 -07:00
Jelle Zijlstra
8f1f3b9abd
gh-104600: Make type.__type_params__ writable ( #104634 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-19 09:04:47 -07:00
Alex Waygood
f7835fc7e9
gh-74690: Don't set special protocol attributes on non-protocol subclasses of protocols ( #104622 )
...
Don't set special protocol attributes on non-protocol subclasses of protocols
2023-05-19 00:34:40 +01:00
Alex Waygood
b27fe67f3c
gh-104555: Runtime-checkable protocols: Don't let previous calls to isinstance()
influence whether issubclass()
raises an exception ( #104559 )
...
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-17 23:43:12 +00:00
Jelle Zijlstra
26931944dd
typing: Add more tests for TypeVar ( #104571 )
...
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.
2023-05-17 06:08:21 -07:00
Alex Waygood
1163782868
gh-104555: Fix isinstance() and issubclass() for runtime-checkable protocols that use PEP 695 ( #104556 )
...
Fixes #104555
2023-05-16 16:38:10 +00:00
Jelle Zijlstra
24d8b88420
gh-103763: Implement PEP 695 ( #103764 )
...
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>
2023-05-15 20:36:23 -07:00
Alex Waygood
c527eb1c2a
gh-91896: Revert some very noisy DeprecationWarnings for ByteString
( #104424 )
2023-05-13 09:55:35 +01:00
Alex Waygood
f0f5bb3204
gh-91896: Improve visibility of ByteString
deprecation warnings ( #104294 )
2023-05-11 23:01:31 -07:00
Franek Magiera
2d526cd32f
GH-103629: Update Unpack's repr in compliance with PEP 692 ( #104048 )
2023-05-01 17:58:50 +00:00
Kirill Podoprigora
4181d078fc
gh-104036: Fix direct invocation of test_typing ( #104037 )
...
Previously, `python -m test test_typing` worked, but `python Lib/test/test_typing.py` did not.
2023-05-01 13:42:59 +00:00
Nikita Sobolev
3d29edaf0a
gh-103746: Test types.UnionType
and Literal
types together ( #103747 )
2023-04-24 10:55:16 -06:00
Nikita Sobolev
5041c2ba6e
gh-103592: Add tests of Literal
with Enum
and Union
of Literal
s ( #103706 )
2023-04-23 11:50:23 -06:00
Adrian Garcia Badaracco
0056701aa3
GH-103699: Add __orig_bases__
to various typing classes ( #103698 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-04-23 08:33:39 -06:00
Nikita Sobolev
a28e2ce3fb
gh-103395: Improve typing._GenericAlias.__dir__
coverage ( #103396 )
2023-04-10 12:09:19 +01:00
Alex Waygood
800382a2b0
gh-74690: Add more tests for runtime-checkable protocols ( #103347 )
2023-04-07 18:21:19 +01:00
Alex Waygood
6d59c9e32e
gh-102433: Use inspect.getattr_static
in typing._ProtocolMeta.__instancecheck__
( #103034 )
2023-04-02 14:22:19 +01:00
Nikita Sobolev
60bdc16b45
gh-103054: typing: Improve Callable
type substitution tests ( #103055 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
2023-03-28 20:04:26 -07:00
Nikita Sobolev
adb0621652
gh-88965: typing: fix type substitution of a list of types after initial ParamSpec
substitution ( #102808 )
...
Previously, this used to fail:
```py
from typing import *
T = TypeVar("T")
P = ParamSpec("P")
class X(Generic[P]):
f: Callable[P, int]
Y = X[[int, T]]
Z = Y[str]
```
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-23 16:26:11 +00:00
Nikita Sobolev
fbe82fdd77
gh-102721: Improve coverage of _collections_abc._CallableGenericAlias
( #102722 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-16 14:47:30 +00:00
Nikita Sobolev
2b5781d659
gh-102615: Use list
instead of tuple
in repr
of paramspec ( #102637 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-15 09:33:41 +00:00
Alex Waygood
5ffdaf748d
gh-102433: Add tests for how classes with properties interact with isinstance()
checks on typing.runtime_checkable
protocols ( #102449 )
...
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-03-11 01:20:20 +00:00
Alex Waygood
96e1022929
gh-102444: Fix minor bugs in test_typing
highlighted by pyflakes ( #102445 )
2023-03-05 21:37:29 +00:00
JosephSBoyle
7894bbe94b
Fix unused classes in a typing test (GH-102437)
...
As part of investigation issue https://github.com/python/cpython/issues/102433 , I discovered what I believe to be an error where two classes `CI` and `DI` are not being used. The assertions beneath them act on `C` and `D`, duplicating existing assertions in this test.
Automerge-Triggered-By: GH:AlexWaygood
2023-03-05 07:07:44 -08:00
Nikita Sobolev
12011dd8ba
gh-102324: Improve tests of typing.override
( #102325 )
...
Fixes #101564
2023-03-02 19:59:05 -08:00
Steven Troxler
0f89acf6cc
gh-101561: Add typing.override decorator ( #101564 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-02-27 13:16:11 -08:00
Eclips4
b96b344f25
gh-101562: typing: add tests for inheritance with NotRequired & Required in parent fields ( #101563 )
2023-02-06 11:28:24 -08:00
Nikita Sobolev
807d6b576f
gh-101015: Fix typing.get_type_hints
with unpacked *tuple
(PEP 646) ( #101031 )
2023-01-23 07:52:58 +00:00
Erik De Bonte
5c19050546
gh-99957: Add frozen_default
parameter on dataclass_transform
( #99958 )
2022-12-05 19:35:43 -08:00
Serhiy Storchaka
8f2fb7dfe7
gh-99344, gh-99379, gh-99382: Fix issues in substitution of ParamSpec and TypeVarTuple (GH-99412)
...
* Fix substitution of TypeVarTuple and ParamSpec together in user generics.
* Fix substitution of ParamSpec followed by TypeVarTuple in generic aliases.
* Check the number of arguments in substitution in user generics containing a
TypeVarTuple and one or more TypeVar.
2022-11-29 09:46:52 +02:00
Nikita Sobolev
a0bc75e2fd
test_typing
: use all pickle protocols (#99154 )
2022-11-06 11:53:57 +00:00