prefer-required-constructor-parameters
Prefer required constructor parameters so callers choose dependencies and configuration explicitly.
Why
Defaulted constructor parameters hide choices at the composition boundary. Replacing None with an empty string, a constant, or a factory still permits an implicit choice. A required nullable parameter makes a meaningful absent value explicit without inventing a sentinel.
Fix
Require the parameter and update callers to pass their choice explicitly; preserve meaningful None values. Suppress intentional framework or public-library defaults with a compatibility reason.
Examples
class Service: def __init__(self, agent_name: str = "") -> None: self.agent_name = agent_nameclass Service: def __init__(self, agent_name: str | None) -> None: self.agent_name = agent_nameFormerly: discourage-nullable-constructor-parameters