-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-inferenceWhen to infer types or require explicit annotationsWhen to infer types or require explicit annotationstopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
Bug Report
Slot definition in a form of __slots__ = [] raise an error:
ex.py:2: error: Need type annotation for "__slots__" (hint: "__slots__: List[<type>] = ...")
To Reproduce
Run mypy on this code:
class A:
__slots__ = []Expected Behavior
I expect it to have the same effect as:
class A:
__slots__ = ()and to produce no errors.
Moreover, mypy already knows that __slots__ should contain str items only as shown here:
class A:
__slots__ = [1, 2]Outputs:
ex.py:2: error: List item 0 has incompatible type "int"; expected "str"
ex.py:2: error: List item 1 has incompatible type "int"; expected "str"
Refs Textualize/rich#1364
smheidrich, tmccombs, herebebeasties, j-baker, blakemorgan and 1 more
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-inferenceWhen to infer types or require explicit annotationsWhen to infer types or require explicit annotationstopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly