-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
B024: ruff in pre-commit fails to recognise B024 with the presence of a class variable #14455
Comments
Thank you for submitting this issue! This behavior is intentional - it is assumed that an unassigned, annotated class variable is intended to be abstract. But that has certainly been a point of discussion/refinement. See this flake8-bugbear issue and the issues linked therein. Let us know if you think it should be further refined! |
Hi, thank you for the reply. In such a case, the documentation needs to be updated. For example, in abstract-base-class-without-abstract-method, instead of
we can write
Please let me know if I can continue completing and implementing this idea. |
That'd be great! I think the check only skips if the class variable is annotated and not assigned, though. So you may want to adjust the wording a bit, maybe:
|
I am working on the documentation. Meanwhile, upon checking the Python documentation, it turns out that only when subscribed by class Starship:
stats: ClassVar[dict[str, int]] = {} # class variable
damage: int = 10 # instance variable What I had as an example in the original post is therefore an instance variable, not a class variable. This contradicts the discussion in PyCQA/flake8-bugbear#293, which only has to do with |
Hey @cmp0xff - you'll want to open a PR for ruff/crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs Lines 13 to 19 in 3c52d2d
That's an interesting point... can you open a separate issue for this? For the present issue let's just change the documentation. Thank you! |
# Summary Closes #14455, migrated from astral-sh/docs#106.
List of keywords I searched for before creating this issue
B024
A minimal code snippet that reproduces the bug
The command you invoked
The current Ruff settings
Relevant snippet of
.pre-commit-config.yaml
Relevant snippet of
pyproject.py
The current Ruff version
0.7.4
The text was updated successfully, but these errors were encountered: