Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mypy complains when[] is used for__slots__ definition #10870

Closed
Labels
bugmypy got something wrongtopic-inferenceWhen to infer types or require explicit annotationstopic-runtime-semanticsmypy doesn't model runtime semantics correctly
@sobolevn

Description

@sobolevn

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

Runmypy on this code:

classA:__slots__= []

Expected Behavior
I expect it to have the same effect as:

classA:__slots__= ()

and to produce no errors.
Moreover,mypy already knows that__slots__ should containstr items only as shown here:

classA:__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"

RefsTextualize/rich#1364

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-inferenceWhen to infer types or require explicit annotationstopic-runtime-semanticsmypy doesn't model runtime semantics correctly

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp