-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
PT006 issue not raised when keyword arguments are used instead of positional arguments. #15324
Comments
caarmen
changed the title
PT006 doesn't raise issues when keyword arguments are used.
PT006 issue not raised when keyword arguments are used instead of positional arguments.
Jan 7, 2025
Currently keyword arguments are only detected in preview mode: (from let names = if checker.settings.preview.is_enabled() {
call.arguments.find_argument_value("argnames", 0)
} else {
call.arguments.find_positional(0)
};
let values = if checker.settings.preview.is_enabled() {
call.arguments.find_argument_value("argvalues", 1)
} else {
call.arguments.find_positional(1)
}; These were added in #14699. The corresponding issue #11243 doesn't have any relevant information, so the reason was probably backward compatibility. Perhaps it's safe to remove these preview checks; I think this is by no mean a breaking change, even when |
dhruvmanila
added
rule
Implementing or modifying a lint rule
preview
Related to preview mode features
labels
Jan 8, 2025
MichaReiser
pushed a commit
that referenced
this issue
Jan 8, 2025
…ze` calls" (`PT006`) (#15327) Co-authored-by: Micha Reiser <[email protected]> Resolves #15324. Stabilizes the behavior changes introduced in #14515.
MichaReiser
pushed a commit
that referenced
this issue
Jan 8, 2025
…ze` calls" (`PT006`) (#15327) Co-authored-by: Micha Reiser <[email protected]> Resolves #15324. Stabilizes the behavior changes introduced in #14515.
MichaReiser
pushed a commit
that referenced
this issue
Jan 8, 2025
…ze` calls" (`PT006`) (#15327) Co-authored-by: Micha Reiser <[email protected]> Resolves #15324. Stabilizes the behavior changes introduced in #14515.
MichaReiser
pushed a commit
that referenced
this issue
Jan 9, 2025
…ze` calls" (`PT006`) (#15327) Co-authored-by: Micha Reiser <[email protected]> Resolves #15324. Stabilizes the behavior changes introduced in #14515.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
For pytest checks:
When
argnames
andargvalues
are passed as keyword arguments topytest.mark.parametrize
, ruff doesn't raisePT006
where it would otherwise (for passing a list instead of a single value).Details
Steps to reproduce the issue:
Create a test file
test_something.py
, containing two test functions.Note that the test functions only expect a single parametrized argument.
In both cases, the
parametrize()
decorator is called with a list forargnames
and a list of list forargvalues
. The difference is that the first one uses positional arguments, and the second one uses keyword arguments.Run ruff explicitly looking for the
PT006
issue:Expected behavior (I think, you'll confirm 😅 ):
PT006
with the same message for both test functions: "Use a string for the first argument".Actual behavior:
The text was updated successfully, but these errors were encountered: