-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Mypy complains when []
is used for __slots__
definition
#10870
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I would love to fix this. PR is incomming! 👍 |
Ok, we can generalize this problem to this case: from typing import List
class Super:
a: List[int]
class Child(Super):
a = [] Right now it reports:
The question is: should partial type be resolved in this general case? If yes, then I can modify the type checker to do it. |
Work around python/mypy#10870 - Mypy complains when [] is used for __slots__ definition generated\nidaqmx\_base_interpreter.py:8: error: Need type annotation for "__slots__" (hint: "__slots__: List[<type>] = ...") [var-annotated] Signed-off-by: Brad Keryan <brad.keryan@ni.com>
Work around python/mypy#10870 - Mypy complains when [] is used for __slots__ definition generated\nidaqmx\_base_interpreter.py:8: error: Need type annotation for "__slots__" (hint: "__slots__: List[<type>] = ...") [var-annotated] Signed-off-by: Brad Keryan <brad.keryan@ni.com>
#13494 which, AFAICT, should have fixed the generalized case mentioned by @sobolevn has been merged by now, but this is still broken for |
This is breaking default protobuf generated code type checking which is a shame. (See mentioned issues above.) Would be lovely to get this sorted out. 👍🏻 |
Bug Report
Slot definition in a form of
__slots__ = []
raise an error:To Reproduce
Run
mypy
on this code:Expected Behavior
I expect it to have the same effect as:
and to produce no errors.
Moreover,
mypy
already knows that__slots__
should containstr
items only as shown here:Outputs:
Refs Textualize/rich#1364
The text was updated successfully, but these errors were encountered: