Loading topic
str | None syntax works at runtime.2 min readX | Y syntax is evaluated at runtime, so it needs 3.10 or newer.2 min readstr | None. Narrowing is how a checker turns a wide union into a specific type inside part of a function.2 min readAny does when it appears.2 min readNone. You should also know that mypy and Pyright are static checkers that never run your code.2 min readmypy and pyright from the command line (covered earlier) and that your project already has a pyproject.toml. Putting both configurations in that one file keeps the settings next to your dependencies and gives every developer and CI job the same results.2 min readpyproject.toml, and read their error messages. It also assumes you know that unannotated code is treated as Any.2 min readAny means. Sometimes a checker reports an error that you cannot fix with better annotations. The cause might be a library with poor types, a limit in the checker, or code that2 min readreveal_type. Both tools implement the same typing standards, so most correct code passes in both. They disagree in defaults, inference rules, and tooling, and those differences explain most of the surprises you will2 min readAny, # type: ignore and strict mode do. A real project may have thousands of unannotated functions, and turning on strict mode there produces thousands of errors that nobody will fix in one sitt2 min readmypy and pyright from the command line and that your settings are in pyproject.toml, as covered in the configuration chapters. It also assumes your project uses a virtual environment.2 min read