Skip to content

no-nullable-dependency-fallback

Require concrete function dependencies instead of resolving a None default inside the function.

Why

A None dependency silently selects another implementation or ambient configuration, hiding wiring mistakes and adding unnecessary branches.

Fix

Resolve the dependency at the call site and pass it explicitly; a concrete callable default is also valid when its lifetime is appropriate.

Examples

Before — flagged Omission silently selects an implementation
app/service.py
def run(factory: Factory | None = None):
return (factory or DefaultFactory)()
After — preferred Caller supplies a concrete dependency
app/service.py
def run(factory: Factory):
return factory()