◐ Shell
clean mode source ↗

typing: Add more tests for TypeVar by JelleZijlstra · Pull Request #104571 · python/cpython

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.

@JelleZijlstra

AlexWaygood

JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this pull request

May 17, 2023
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..
(cherry picked from commit 2693194)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

JelleZijlstra added a commit that referenced this pull request

May 17, 2023
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.
(cherry picked from commit 2693194)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

carljm added a commit to carljm/cpython that referenced this pull request

May 17, 2023

JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this pull request

May 18, 2023
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.

JelleZijlstra added a commit to JelleZijlstra/typing_extensions that referenced this pull request

May 21, 2023
I started out trying to backport python/cpython#104571, but
realized that it makes sense to backport CPython's whole TypeVarTests
class since we now have our own implementation of TypeVar.

I dropped test_var_substitution and test_bad_var_substitution
since they rely on the internal __typing_subst__ method, and the
type substitution logic is generally very hard to get precisely
the same across versions.

JelleZijlstra added a commit to python/typing_extensions that referenced this pull request

May 21, 2023
I started out trying to backport python/cpython#104571, but
realized that it makes sense to backport CPython's whole TypeVarTests
class since we now have our own implementation of TypeVar.

I dropped test_var_substitution and test_bad_var_substitution
since they rely on the internal __typing_subst__ method, and the
type substitution logic is generally very hard to get precisely
the same across versions.