Skip to content
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

[pylint] Implement assigning-non-slot (E0237) #9623

Merged

Conversation

tsugumi-sys
Copy link
Contributor

Summary

Implement assigning-non-slot / E0237

related #970

Test Plan

cargo test

Copy link
Contributor

github-actions bot commented Jan 23, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+2 -0 violations, +0 -0 fixes in 1 projects; 42 projects unchanged)

DisnakeDev/disnake (+2 -0 violations, +0 -0 fixes)

+ disnake/embeds.py:206:9: PLE0237 Attribute `timestamp` is not defined in class's `__slots__`
+ disnake/embeds.py:214:9: PLE0237 Attribute `colour` is not defined in class's `__slots__`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLE0237 2 2 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+2 -0 violations, +0 -0 fixes in 1 projects; 42 projects unchanged)

DisnakeDev/disnake (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ disnake/embeds.py:206:9: PLE0237 Attribute `timestamp` is not defined in class's `__slots__`
+ disnake/embeds.py:214:9: PLE0237 Attribute `colour` is not defined in class's `__slots__`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLE0237 2 2 0 0 0

@charliermarsh
Copy link
Member

How does Pylint handle this for subclasses? E.g., does it allow items in __slots__ that are attributes on superclasses?

@tsugumi-sys
Copy link
Contributor Author

tsugumi-sys commented Jan 24, 2024

@charliermarsh

If subclasses define slots, pylint checks not redefining the same slots as its superclass in redefined-slots-in-subclass / W0244.

Also we can set new slots in the superclass and pylint checks it in assigning-non-slot / E0237.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tsugumi-sys, I limited the rule to classes that don't inherit from "unknown" parent classes for now.

We actually have support for resolving parent classes within the same file, so we could extend the rule to check that.

@charliermarsh charliermarsh added rule Implementing or modifying a lint rule preview Related to preview mode features labels Jan 24, 2024
@charliermarsh charliermarsh changed the title [pylint] - implement assigning-non-slot/E0237 [pylint] Implement assigning-non-slot (E0237) Jan 24, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) January 24, 2024 02:45
@charliermarsh charliermarsh merged commit 57313d9 into astral-sh:main Jan 24, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants