-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
attrs plugin should support attrs.evolve #14525
Comments
Similar treatment for |
By modifying the type annotations? I don't think dataclasses have any common base, do they? Or maybe through a protocol? |
Yes, @AlexWaygood suggested doing it with a protocol: python/typeshed#9362 |
Applying the same technique to |
If attrs ships its own type annotations, then they could decide that e.g. you could only used them with mypy and a certain plugin being installed, but I agree we cannot make this decision for typeshed's annotations. And for this case, the plugin can easily make this check, and I would have to in #14526 anyway. |
To be clear, |
Validate `attr.evolve` calls to specify correct arguments and types. The implementation makes it so that at every point where `attr.evolve` is called, the signature is modified to expect the attrs class' initializer's arguments (but so that they're all kw-only and optional). Notes: - Added `class dict: pass` to some fixtures files since our attrs type stubs now have **kwargs and that triggers a `builtin.dict` lookup in dozens of attrs tests. - Looking up the type of the 1st argument with `ctx.api.expr_checker.accept(inst_arg)` which is a hack since it's not part of the plugin API. This is a compromise for due to #10216. Fixes #14525.
Feature
In the attrs plugin, we should add special treatment for attrs.evolve.
Pitch
We should validate attr names and types match.
The text was updated successfully, but these errors were encountered: