If you wrap attrs decorators, Mypy's plugin may not recognize the resulting classes. To fix this, you can create a custom Mypy plugin that uses attr_attrib_makers, attr_class_makers, and attr_dataclass_makers to register your custom methods.
Note: This only tells Mypy that a class is an attrs class; it cannot inform Mypy about changes to defaults like eq or order.
from mypy.plugin import Plugin
from mypy.plugins.attrs import (
attr_attrib_makers,
attr_class_makers,
attr_dataclass_makers,
)
# Register your custom methods
attr_dataclass_makers.add("my_module.method_looks_like_attr_dataclass")
attr_class_makers.add("my_module.method_looks_like_attr_s")
attr_attrib_makers.add("my_module.method_looks_like_attrib")
class MyPlugin(Plugin):
pass
def plugin(version):
return MyPlugin
Then add the plugin to your mypy.ini:
[mypy]
plugins=<path to file>