Skip to content
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

mypy 1.5.0 and Item.__slots__ #55

Open
wRAR opened this issue Aug 15, 2023 · 0 comments
Open

mypy 1.5.0 and Item.__slots__ #55

wRAR opened this issue Aug 15, 2023 · 0 comments

Comments

@wRAR
Copy link
Member

wRAR commented Aug 15, 2023

mypy 1.5.0 has an additional warning:

zyte_common_items/base.py:53: error: Trying to assign name "_unknown_fields_dict" that is not in "__slots__" of type "zyte_common_items.base.Item"  [misc]
zyte_common_items/base.py:77: error: Trying to assign name "_unknown_fields_dict" that is not in "__slots__" of type "zyte_common_items.base.Item"  [misc]

Item doesn't define __slots__ but its base class _ItemBase does (and it includes _unknown_fields_dict). _ItemBase is a normal class, Item is decorated with @attrs.define. There are some entries about attr classes and __slots__ in the mypy 1.5.0 changelog, but I don't see if it's a false positive or a newly detected problem in our code. python/mypy#15639 is likely the change that causes this.

Also related:

https://mypy.readthedocs.io/en/stable/class_basics.html#slots

https://www.attrs.org/en/stable/examples.html#slots

https://www.attrs.org/en/stable/glossary.html#term-slotted-classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant