no-hidden-constructor-fallback
Constructor option silently falls back to application settings when omitted.
Why
Hidden configuration lookup obscures dependencies and makes construction vary with ambient application state.
Fix
Require the constructor argument and resolve any default at the composition root or call site.
Examples
from pydantic_settings import BaseSettings
class Settings(BaseSettings): MODEL: str = "model"
settings = Settings()from app.config import settings
class Generator: def __init__(self, *, model: str | None = None) -> None: self.model = model or settings.MODEL
generator = Generator(model="explicit")[project]name = 'example'version = '0.1.0'from pydantic_settings import BaseSettings
class Settings(BaseSettings): MODEL: str = "model"
settings = Settings()class Generator: def __init__(self, *, model: str) -> None: self.model = model
generator = Generator(model="explicit")[project]name = 'example'version = '0.1.0'