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

PLR0917: should this exclude self and cls? #9552

Closed
tmke8 opened this issue Jan 16, 2024 · 1 comment · Fixed by #9563
Closed

PLR0917: should this exclude self and cls? #9552

tmke8 opened this issue Jan 16, 2024 · 1 comment · Fixed by #9563
Labels
rule Implementing or modifying a lint rule

Comments

@tmke8
Copy link
Contributor

tmke8 commented Jan 16, 2024

PLR0917 counts the number of non-keyword-only arguments and checks whether the number is above max-positional-args. This count includes self and cls in methods and class-methods, but I feel like those shouldn't count because they are passed in implicitly.

I'd be willing to make the code change if this is acceptable.

@charliermarsh
Copy link
Member

Yeah, I think it probably should exclude those.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Jan 16, 2024
tmke8 added a commit to tmke8/ruff that referenced this issue Jan 17, 2024
charliermarsh pushed a commit that referenced this issue Jan 18, 2024
…9563)

## Summary

This PR detects whether PLR0917 is being applied to a method or class
method, and if so, it ignores the first argument for the purposes of
counting the number of positional arguments.

## Test Plan

New tests have been added to the corresponding fixture.

Closes #9552.
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 a pull request may close this issue.

2 participants