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

Marking default_error_messages as a ClassVar #2457

Merged

Conversation

delfick
Copy link
Contributor

@delfick delfick commented Dec 6, 2024

This is only ever a dictionary defined on the class and not being defined as a ClassVar means in projects using django-stubs it's not possible to comply with https://docs.astral.sh/ruff/rules/mutable-class-default/

This is only ever a dictionary defined on the class and not being
defined as a ClassVar means in projects using django-stubs it's not
possible to comply with https://docs.astral.sh/ruff/rules/mutable-class-default/
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

You can add this new mypy error code https://mypy.readthedocs.io/en/stable/error_code_list2.html#check-that-overrides-of-mutable-attributes-are-safe-mutable-override in the next PR, just to see how many errors we have. Maybe some of them are worth fixing. Like this one.

@sobolevn sobolevn merged commit 9351ae1 into typeddjango:master Dec 6, 2024
40 checks passed
@delfick delfick deleted the default-error-messages-are-class-vars branch December 6, 2024 08:46
@delfick
Copy link
Contributor Author

delfick commented Dec 6, 2024

@sobolevn mypy --enable-error-code mutable-override is a very funny command for the 6 million line django monolith I work on lol

Found 21195 errors in 5260 files (checked 37001 source files)

On django-stubs it appears only 200 errors :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants