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

Various class based NamedTuple and TypedDict errors not caught #6200

Open
JukkaL opened this issue Jan 16, 2019 · 1 comment
Open

Various class based NamedTuple and TypedDict errors not caught #6200

JukkaL opened this issue Jan 16, 2019 · 1 comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-named-tuple topic-typed-dict

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jan 16, 2019

This example has a bunch of errors that the semantic analyzer should probably report (and one what seems like a false positive):

from typing import NamedTuple, TypeVar, Generic
from typing_extensions import Protocol
from mypy_extensions import TypedDict

@xyz  # No error
class N1(NamedTuple):
   x: int

@xyz  # No error
class T1(TypedDict):
    x: int

class N2(NamedTuple, Protocol):  # No error
   x: int

class T2(TypedDict, Protocol):  # No error
    x: int

class M(type):
    def f(cls) -> None: pass

class N3(NamedTuple, metaclass=M):  # No error
   x: int

N3.f()  # Error

class T3(TypedDict, metaclass=M):  # No error
    x: int

T = TypeVar('T')

class N4(NamedTuple, Generic[T]):  # No error
   x: int

class T4(TypedDict, Generic[T]):  # No error
   x: int
@AlexWaygood
Copy link
Member

This one now (correctly) causes mypy to emit an error:

@xyz  # error: Name "xyz" is not defined
class T1(TypedDict):
    x: int

The others all continue to reproduce on 0.941.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-named-tuple topic-typed-dict
Projects
None yet
Development

No branches or pull requests

3 participants