Skip to content

mypy 1.5.0 and Item.__slots__ #55

@wRAR

Description

@wRAR

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions