Skip to content
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

Add test case for fixed bug regarding nested generic classes #12652

Merged
merged 1 commit into from
Apr 22, 2022
Merged
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
16 changes: 16 additions & 0 deletions test-data/unit/check-generics.test
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,22 @@ class Outer(Generic[T]):
def g(self) -> None:
y: T # E: Invalid type "__main__.T"

[case testGenericClassInsideOtherGenericClass]
from typing import TypeVar, Generic
T = TypeVar("T")
K = TypeVar("K")

class C(Generic[T]):
def __init__(self, t: T) -> None: ...
class F(Generic[K]):
def __init__(self, k: K) -> None: ...
def foo(self) -> K: ...

reveal_type(C.F(17).foo()) # N: Revealed type is "builtins.int"
reveal_type(C("").F(17).foo()) # N: Revealed type is "builtins.int"
reveal_type(C.F) # N: Revealed type is "def [K] (k: K`1) -> __main__.C.F[K`1]"
reveal_type(C("").F) # N: Revealed type is "def [K] (k: K`1) -> __main__.C.F[K`1]"


-- Callable subtyping with generic functions
-- -----------------------------------------
Expand Down