Skip to content

PT006 breaks when only one argname #24715

@George-Ogden

Description

@George-Ogden

Summary

Pytest has different semantics for single argnames when using a string or a tuple/list.
With a tuple/list, it expects a one-element sequence as each argvalue, so this is valid:

@pytest.mark.parametrize(("number",), [(0,)])

However, with a string, it just expects a list of the argvalues, so this is valid:

@pytest.mark.parametrize("number", [0])

Rule PT006 updates the first case to look like this:

@pytest.mark.parametrize("number", [(0,)])

which now means that "number" is passed as a tuple and probably breaks the test.

I think the best way to fix this is to flag the error and not fix it when there is one argument.

Version

ruff 0.15.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions