This rule raises an issue when an argument-free @pytest.fixture or @pytest.mark.* decorator uses parentheses inconsistently with the configured style.

By default, empty parentheses are not allowed, matching the official pytest documentation. Analysis may be configured to require empty parentheses instead.

Why is this an issue?

For argument-free @pytest.fixture and @pytest.mark.* decorators, parentheses are optional:

@pytest.fixture
def sample():
    return 1

@pytest.fixture()
def other():
    return 2

Both forms are valid, but mixing them makes tests harder to scan and review. Prefer one style consistently. The default style omits empty parentheses, which matches pytest’s own documentation.

Decorators that take arguments still need parentheses:

@pytest.fixture(scope='module')
def db():
    ...

@pytest.mark.parametrize('value', [1, 2])
def test_values(value):
    ...

What is the potential impact?

Inconsistent parentheses on fixtures and marks add noise during reviews without changing behavior. Aligning on one style keeps test suites easier to read and maintain.

How to fix it

Omit empty parentheses on argument-free @pytest.fixture and @pytest.mark.* decorators (the default style). If analysis is configured to require parentheses, add empty () instead.

Do not change decorators that already pass arguments.

Code examples

Noncompliant code example

import pytest

@pytest.fixture()  # Noncompliant
def sample():
    return 1

@pytest.mark.slow()  # Noncompliant
def test_sample(sample):
    assert sample == 1

Compliant solution

import pytest

@pytest.fixture
def sample():
    return 1

@pytest.mark.slow
def test_sample(sample):
    assert sample == 1

Resources

Documentation