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

Error isn't provided when TypeVar is defined in both outer and inner class scopes #10479

Open
erictraut opened this issue May 15, 2021 · 0 comments · May be fixed by #18883
Open

Error isn't provided when TypeVar is defined in both outer and inner class scopes #10479

erictraut opened this issue May 15, 2021 · 0 comments · May be fixed by #18883
Labels
bug mypy got something wrong

Comments

@erictraut
Copy link

PEP 484 says "A generic class nested in another generic class cannot use same type variables. The scope of the type variables of the outer class doesn't cover the inner one".

It provides the following example:

from typing import Generic, Iterable, TypeVar

T = TypeVar('T')
S = TypeVar('S')

class Outer(Generic[T]):
    class Bad(Iterable[T]):       # Error
        ...

Mypy does not emit an error in this case even though PEP 484 says it's not allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant