This rule raises an issue when @pytest.fixture options are passed as positional arguments.

In Python, this refers to @pytest.fixture(…​) with options passed as positional arguments, such as @pytest.fixture("module").

Why is this an issue?

Passing options like scope as positional arguments to @pytest.fixture is ambiguous and has been removed in pytest 6.0 and later. Use keyword arguments:

@pytest.fixture("module")  # Removed; use keyword arguments
def shared_state():
    return {}

Prefer:

@pytest.fixture(scope="module")
def shared_state():
    return {}

What is the potential impact?

Positional arguments to @pytest.fixture are rejected by modern pytest, so fixtures written this way fail to load or raise errors at collection time.

How to fix it

Pass fixture options with keywords (for example scope="module").

Code examples

Noncompliant code example

import pytest

@pytest.fixture("module")  # Noncompliant
def scoped():
    return []

Compliant solution

import pytest

@pytest.fixture(scope="module")
def scoped():
    return []

Resources

Documentation

Related rules