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

[ruff] Fix invalid annotation in docs example #16016

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

AlexWaygood
Copy link
Member

Summary

Unfortunately the edits made by #15982 mean that the annotations in the second "Use instead" example are now incorrect, and would be rejected by a type checker. This is because instance_dict is declared as a ClassVar variable in the class body, which declares to the type checker that it is illegal to set the attribute on instances of the class (it can only be set on the class object itself). The attribute is then assigned to self in the __init__ instance method, violating the annotation in the class body.

This PR fixes the incorrect annotation and adds a couple more examples.

Test Plan

N/A

@AlexWaygood AlexWaygood added the documentation Improvements or additions to documentation label Feb 7, 2025
@AlexWaygood AlexWaygood enabled auto-merge (squash) February 7, 2025 10:42
@AlexWaygood AlexWaygood merged commit b1c61cb into main Feb 7, 2025
20 checks passed
@AlexWaygood AlexWaygood deleted the alex/invalid-docs-annotation branch February 7, 2025 10:45
Copy link
Contributor

github-actions bot commented Feb 7, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

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

Successfully merging this pull request may close these issues.

1 participant