-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Allow to register new class/dataclass/attribute makers in attrs plugin #5406
Comments
FYI in our code I literally append to these lists in a mypy plugin. I did have a vision that the plugin could support an So you'd do:
Or something like that. |
Another possible pattern we can support is: if TYPE_CHECKING:
custom_maker = attr.s
else:
def custom_maker(cls):
... |
The same problem exists for dataclasses, see #6239 |
Just FTR cross-posting the workaround that currently works: from typing import TYPE_CHECKING
if TYPE_CHECKING:
from attr import s as custom_maker
else:
def custom_maker(cls):
... but it is arguably worse than #5406 (comment), that currently doesn't work. |
Heh. Here's what I did in our code base. I added a plugin that adds some methods when imported. (Did y'all wonder why I made those variables globals?)
|
Copied from 'python/mypy#5406 (comment)' rather than following the rest of the hack there.
This is a feature request.
attrs
is very much intended to be composable (e.g. https://github.com/hynek/environ_config) but currently the attrs plugin only works on the core library's functions:mypy/mypy/plugins/attrs.py
Lines 24 to 37 in b2d6174
I would like to be able to signal somehow to mypy, that some function is a wrapper around
@attr.s
/@attr.ib
/@attr.dataclass
. Not only would third-party applications benefit, but I could really use it while experimenting on python-attrs/attrs#408.Any ideas/plans how we could achieve that?
cc also @euresti & @chadrik
The text was updated successfully, but these errors were encountered: