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

chore: ignore cls type annotations on linter #12428

Merged
merged 1 commit into from
Aug 22, 2024
Merged

Conversation

davidcavazos
Copy link
Contributor

@davidcavazos davidcavazos commented Aug 20, 2024

Description

We're currently ignoring ANN101 which is for self type annotations on methods. We should probably also ignore ANN102 which is for cls type annotations on @classmethod. It's basically the same as self, but instead of being a reference to the object, it's a reference to the class.

The Self type annotation is redundant (the same class name) and does not give any additional information. Even in the official Python type hints documentation, they don't annotate self, for example here. Even though they don't explicitly mention the recommended style, they do mention that the Self type is usually used for return types of the same class, rather than for annotating self or cls.

Checklist

@davidcavazos davidcavazos requested a review from a team as a code owner August 20, 2024 18:56
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Aug 20, 2024
Copy link
Contributor

@iennae iennae left a comment

Choose a reason for hiding this comment

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

Thanks @davidcavazos

@davidcavazos davidcavazos merged commit 0c3cc75 into main Aug 22, 2024
15 checks passed
@davidcavazos davidcavazos deleted the update-lint-rules branch August 22, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants