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

Avoid ANN2xx autofix for abstract methods with empty body #9034

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

dhruvmanila
Copy link
Member

Summary

This PR updates the ANN201, ANN202, ANN205, and ANN206 rules to not create a fix for the return type when it's an abstract method and the function body is empty i.e., it only contains either a pass statement, docstring or an ellipsis literal.

fixes: #9004

Test Plan

Add the following test cases:

  • Abstract method with pass statement
  • Abstract method with docstring
  • Abstract method with ellipsis literal
  • Abstract method with possible return type

@dhruvmanila
Copy link
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@dhruvmanila
Copy link
Member Author

(I hope I understood the issue correctly 😅)

@dhruvmanila dhruvmanila added the rule Implementing or modifying a lint rule label Dec 7, 2023
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.

Looks right to me!

Copy link
Contributor

github-actions bot commented Dec 7, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@dhruvmanila dhruvmanila merged commit 9361e22 into main Dec 7, 2023
17 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/auto-return branch December 7, 2023 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable ANN201 None-autofix for abstractmethods?
2 participants