Skip to content

Various class based NamedTuple and TypedDict errors not caught #6200

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

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

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.

@ilevkivskyi ilevkivskyi removed the false-positive mypy gave an error on correct code label Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants