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").
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 {}
Positional arguments to @pytest.fixture are rejected by modern pytest, so fixtures written this way fail to load or raise errors at
collection time.
Pass fixture options with keywords (for example scope="module").
import pytest
@pytest.fixture("module") # Noncompliant
def scoped():
return []
import pytest
@pytest.fixture(scope="module")
def scoped():
return []