Python Static Type Checker

Python Static Type Checker

mypy-lang.org

2

About this website

A static type checker for Python that combines the expressiveness of dynamic typing with the safety of compile-time type checking, catching type errors before code execution. Originally created as part of a PhD thesis on gradual typing, the tool has become the reference implementation for Python type checking, maintaining compatibility with PEP 484 and subsequent type system proposals including PEP 695 generic syntax, PEP 692 typed kwargs, and PEP 698 override decorator support. The checker understands the full Python type system including generics, protocols, callable types, literal types, union and intersection types, overloads, type narrowing through isinstance checks and conditional expressions, and exhaustiveness checking for enums and literal unions. Incremental checking mode caches type information between runs, enabling fast feedback loops in large codebases by only re-checking changed modules and their dependents. The daemon mode keeps the type checker running in the background for near-instant feedback on file saves. Strict mode progressively enables additional checks including disallow of untyped function definitions, disallow of Any types, require complete signatures, and warn on returning Any from functions annotated with concrete types. Plugin architecture allows third-party type stubs and plugins to improve inference for libraries that use dynamic patterns like SQLAlchemy declarative models, Django models, dataclasses with __init_subclass__, and protocol-based dependency injection. The tool generates HTML coverage reports showing which functions and modules have type annotations, enabling teams to track progress in adding types to legacy codebases. Integration with popular frameworks includes plugin support for Django, Flask, Pydantic, attrs, and NumPy.

Tags & Categories

Statistics

2
Views
0
Clicks
0
Like
0
Dislike

Comments

Log In to post a comment

No comments yet. Be the first!