Hacker News new | ask | show | jobs
by zbentley 15 hours ago
That’s the bare minimum because it’s the set of features where partial type checking is worse than no type checking, not because I think it represents the average Django application.

For example, if a type checker can accurately analyze objects.filter(x=Foo()) for a foreign keyed Foo, and require that “x” have that type, that seems useful on its own … but if the type checker then does not check the types of x__in=[Foo(), Bar()], that’s worse than useless: folks will get used to type protection in the first case and expect it in the latter, and be disappointed in the form of production bug rates going up.

That’s why I picked the features I did for “Django bare minimum” type checking. If you typecheck that stuff any less than really thoroughly, correctly, and covnveniently, the ROI of the type checker may become negative.

That’s why, for many projects, I find “type annotate and check business logic, leave Django largely un-checked (consider annotations to be notes for humans) and prioritize test coverage there instead” to be the right move.