A fast Python linter that forbids function and dataclass defaults.
Actively maintained. Last release 3 months ago, commits in 17 of the last 26 weeks. A safe choice.
pip install no-defaultsno-defaults
A fast, standalone Python linter that forbids defaults in function signatures, dataclasses, and pydantic models — and removes them for you, updating the call sites in the files you checked so the code still runs. It is implemented in Rust and parses Python with Ruff's parser.
from dataclasses import dataclass, field
from pydantic import BaseModel, Field
def connect(timeout=30): # NOD001
pass
@dataclass
class Job:
retries: int = 3 # NOD001
tags: list[str] = field(default_factory=list) # NOD001
class Request(BaseModel):
method: str = "GET" # NOD001
headers: dict[str, str] = Field(default_factory=dict) # NOD001
url: str = Field(..., description="required, so no default to remove")
Installation
uv tool install no-defaults
The Python package installs ty alongside
no-defaults. If you install the Rust binary with Cargo instead, install ty
separately and make it available on PATH; cross-package callback resolution
uses the supported ty server interface and fails explicitly when it is absent.
Usage
no-defaults . # check
no-defaults --fix . # remove defaults, update call sites
no-defaults --diff . # preview the same edits, write nothing
no-defaults --private-only src tests # only underscore-prefixed names
no-defaults --private-only --respect-reexports src # ... minus ones re-exported publicly
no-defaults --output-format json . # also: full, concise, github
no-defaults --show-settings src/package/api.py # the settings that apply to a file
Exit status is 0 when clean, 1 when violations are found, and 2 for an operational error — including a path named on the command line that is not a .py or .pyi file, so a mistyped path fails rather than reporting a clean run over nothing. Directories are walked in parallel for Python files, respecting .gitignore and hidden-file filters.