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

Refactor FunctionArgNamesCheck (N803,N804,N805) #225

Merged
merged 1 commit into from Nov 7, 2023

Conversation

jparise
Copy link
Member

@jparise jparise commented Oct 22, 2023

The previous implementation repeated the N803 (lowercase name) check three times. This change reworks the function's logic to avoid code duplication. It also let me remove some nested function calls.

In the process, I noticed two additional things that could be improved (but I'm only doing one of them here):

  1. We were previously returning after the first naming error, perhaps as an optimization, but I think it's more helpful to return all of the errors we can detect from within this check.

  2. The "ignored names" set is (unnecessarily?) used for the N804/N805 first argument checks. We have some test cases that expected this behavior, so I'm retaining it for backwards compatibility.

The previous implementation repeated the N803 (lowercase name) check
three times. This change reworks the function's logic to avoid code
duplication. It also let me remove some nested function calls.

In the process, I noticed two additional things that could be improved
(but I'm only doing one of them here):

1. We were previously returning after the first naming error, perhaps
   as an optimization, but I think it's more helpful to return all of
   the errors we can detect from within this check.

2. The "ignored names" set is (unnecessarily?) used for the N804/N805
   first argument checks. We have some test cases that expected this
   behavior, so I'm retaining it for backwards compatibility.
@jparise
Copy link
Member Author

jparise commented Nov 7, 2023

@sigmavirus24 how does this refactor look to you?

@jparise jparise merged commit 975beed into PyCQA:main Nov 7, 2023
6 checks passed
@jparise jparise deleted the functiondef-args branch November 7, 2023 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants