Open
Description
Bug Report, To Reproduce, & Actual Behaviour
See mypy Playground:
from collections.abc import Callable
class A:
__slots__ = ()
a: int
b: Callable[[int], str]
def __init__(self, /) -> None:
self.a = 1 # E: Trying to assign name "a" that is not in "__slots__" of type "__main__.A" [misc]
self.b = lambda _: str(_) # No warning
Expected Behavior
from collections.abc import Callable
class A:
__slots__ = ()
a: int
b: Callable[[int], str]
def __init__(self, /) -> None:
self.a = 1 # E: Trying to assign name "a" that is not in "__slots__" of type "__main__.A" [misc]
self.b = lambda _: str(_) # E: Trying to assign name "b" that is not in "__slots__" of type "__main__.A" [misc]
Your Environment
- Mypy version used: (Occurs as far back as 1.0.0)
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.9, 3.12