It was a bear to get set up (oh NixOS...), but I imagine it's easier on other platforms: `pytype` from Google is the God Linter for Python.

It:

- seamlessly supports everything from old-ass Python 2 code up to very recent (like 3.10 or someting)

- it can and does exploit `mypy`-style annotations, but needs none to deeply analyze your code and actually find bugs

- it seems to do fairly serious deep PLT magicks. i admittedly haven't dived deep here but it's doing stuff that looks like escape analysis-level whole-program analysis

- it heavily caches and optimizes it's (understandably) heavy lifting via Ninja

It demolishes everything else I've tried. I will definitely take `Ruff` for a spin, we've got a lot of Python and I'm always up for discovering there's a better tool, but the dark magic PLT wizards at Google have probably gotten pretty close to what can be done.

pytype dev here - thanks for the kind words :) whole-program analysis on unannotated or partially-annotated code is our particular focus, but there's surprisingly little dark PLT magic involved, and you certainly don't need to be an academic type theory wizard to understand how it works. our developer docs[1] have more info, but at a high level we have an interpreter that virtually executes python bytecode, tracking types where the cpython interpreter would have tracked values.

it's worth exploring some of the other type checkers as well, since they make different tradeoffs - in particular, microsoft's pyright[2] (written in typescript!) can run incrementally within vscode, and tends to add new and experimentally proposed typing PEPs faster than we do.

[1] https://github.com/google/pytype/blob/main/docs/developers/i...

[2] https://github.com/microsoft/pyright