Skip to content

redundant-test-constructor-forwarder

A private test helper mirrors a resolved value-record constructor without adding a contract.

Why

A forwarding helper repeats the constructor's fields and types, creating a second signature to maintain without scenario defaults or setup.

Fix

Use the real typed constructor at known callers. Keep helpers that choose defaults, transform data, own resources, narrow types, or provide an intentional patch boundary.

Examples

Before — flagged Required parameters only repeat record fields
tests/__init__.py
# Example test package.
tests/test_record.py
from pydantic import BaseModel
class Record(BaseModel):
value: str
def _record(value: str) -> Record:
return Record(value=value)
def test_record():
assert _record("item").value == "item"
After — preferred The record owns its signature and validation
tests/__init__.py
# Example test package.
tests/test_record.py
from pydantic import BaseModel
class Record(BaseModel):
value: str
def test_record():
assert Record(value="item").value == "item"