Skip to content

[3.12] gh-105437: Improve tests of type params names for PEP 695 (GH-105438) #105452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Lib/test/test_type_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@


class TypeParamsInvalidTest(unittest.TestCase):
def test_name_collision_01(self):
check_syntax_error(self, """type TA1[A, **A] = None""", "duplicate type parameter 'A'")
def test_name_collisions(self):
check_syntax_error(self, 'type TA1[A, **A] = None', "duplicate type parameter 'A'")
check_syntax_error(self, 'type T[A, *A] = None', "duplicate type parameter 'A'")
check_syntax_error(self, 'type T[*A, **A] = None', "duplicate type parameter 'A'")

def test_name_non_collision_02(self):
ns = run_code("""type TA1[A] = lambda A: A""")
Expand Down
10 changes: 8 additions & 2 deletions Lib/test/test_type_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@


class TypeParamsInvalidTest(unittest.TestCase):
def test_name_collision_01(self):
check_syntax_error(self, """def func[**A, A](): ...""")
def test_name_collisions(self):
check_syntax_error(self, 'def func[**A, A](): ...', "duplicate type parameter 'A'")
check_syntax_error(self, 'def func[A, *A](): ...', "duplicate type parameter 'A'")
check_syntax_error(self, 'def func[*A, **A](): ...', "duplicate type parameter 'A'")

check_syntax_error(self, 'class C[**A, A](): ...', "duplicate type parameter 'A'")
check_syntax_error(self, 'class C[A, *A](): ...', "duplicate type parameter 'A'")
check_syntax_error(self, 'class C[*A, **A](): ...', "duplicate type parameter 'A'")

def test_name_non_collision_02(self):
ns = run_code("""def func[A](A): return A""")
Expand Down