Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JukkaL committed May 17, 2024
1 parent 37f4488 commit b82c9cd
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -1104,3 +1104,36 @@ def g[T](x: T) -> T:
def nested2[S](y: S) -> S:
return y
return x

[case testPEP695NestedScopingSpecialCases]
# mypy: enable-incomplete-feature=NewGenericSyntax
# This is adapted from PEP 695
S = 0

def outer1[S]() -> None:
S = 1
T = 1

def outer2[T]() -> None:
def inner1() -> None:
nonlocal S
nonlocal T # E: nonlocal binding not allowed for type parameter "T"

def inner2() -> None:
global S

[case testPEP695ScopingWithBaseClasses]
# mypy: enable-incomplete-feature=NewGenericSyntax
# This is adapted from PEP 695
class Outer:
class Private:
pass

# If the type parameter scope was like a traditional scope,
# the base class 'Private' would not be accessible here.
class Inner[T](Private, list[T]):
pass

# Likewise, 'Inner' would not be available in these type annotations.
def method1[T](self, a: Inner[T]) -> Inner[T]:
return a

0 comments on commit b82c9cd

Please sign in to comment.