brain_attrs: Support annotation-only members#2515
Merged
Pierre-Sassoulas merged 1 commit intopylint-dev:maintenance/3.3.xfrom Aug 27, 2024
Merged
brain_attrs: Support annotation-only members#2515Pierre-Sassoulas merged 1 commit intopylint-dev:maintenance/3.3.xfrom
Pierre-Sassoulas merged 1 commit intopylint-dev:maintenance/3.3.xfrom
Conversation
Similar to dataclasses, the following class which uses instance
variable annotations is valid:
```py
@attrs.define
class AttrsCls:
x: int
AttrsCls(1).x
```
However, before this commit astroid failed to transform the class
attribute into an instance attribute and this led to `no-member` errors
in pylint.
Only the new `attrs` API supports this form out-of-the-box, so just
address the common case.
Closes pylint-dev#2514
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## maintenance/3.3.x #2515 +/- ##
====================================================
Coverage ? 92.99%
====================================================
Files ? 93
Lines ? 11043
Branches ? 0
====================================================
Hits ? 10269
Misses ? 774
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more.
|
DanielNoord
approved these changes
Aug 25, 2024
Contributor
Author
|
Thank you. Daniel Will you merge it? I don’t have the permissions.
…On Sun, Aug 25, 2024 at 4:24 PM Daniël van Noord ***@***.***> wrote:
***@***.**** approved this pull request.
—
Reply to this email directly, view it on GitHub
<#2515 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADRDKR3K33P5M5L2JZDK6LZTI4O7AVCNFSM6AAAAABM7KMIBGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDENJZGM3DOMRYHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Pierre-Sassoulas
approved these changes
Aug 27, 2024
Member
|
Thank you @Hnasar, clean PR ! |
Member
|
@Hnasar for your next contribution, could you always target |
Member
Never mind, this will be taken care of in our usual release process. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Similar to dataclasses, the following class which uses instance variable annotations is valid:
However, before this commit astroid failed to transform the class attribute into an instance attribute and this led to
no-membererrors in pylint.Only the new
attrsAPI supports this form out-of-the-box, so just address the common case.Type of Changes
Closes #2514