Skip to content

Avoid ANN2xx autofix for abstract methods with empty body#9034

Merged
dhruvmanila merged 1 commit intomainfrom
dhruv/auto-return
Dec 7, 2023
Merged

Avoid ANN2xx autofix for abstract methods with empty body#9034
dhruvmanila merged 1 commit intomainfrom
dhruv/auto-return

Conversation

@dhruvmanila
Copy link
Copy Markdown
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
Copy Markdown
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@dhruvmanila
Copy link
Copy Markdown
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
Copy Markdown
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!

@github-actions
Copy link
Copy Markdown
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
@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