mypy-extensions
Type system extensions for programs checked with the mypy type checker.
This package has a good security score with no known vulnerabilities.
Community Reviews
Essential low-friction utilities for advanced type hinting in Python
The documentation is sparse, but that's actually okay since most of the extensions are well-documented in PEP specifications and mypy's own docs. When you need TypedDict for structured dictionaries or Protocol for structural subtyping, you just import and use them - they work exactly as expected with excellent mypy integration. Error messages come from mypy itself, so they're as good as your type checker.
The main gotcha is understanding that many of these features have been backported to typing or typing_extensions, so you might occasionally wonder which package to import from. For new projects targeting Python 3.8+, you'll increasingly use typing_extensions instead, but mypy-extensions remains relevant for specific mypy features like NewType and other checker-specific functionality.
Best for: Projects using mypy that need advanced typing features not yet in your Python version's standard library.
Avoid if: You're targeting Python 3.10+ only and can use built-in typing features or prefer typing_extensions for broader compatibility.
Essential typing utilities with minimal friction, but sparse documentation
The learning curve is gentle because the package is small and focused. When you need something like @mypyc_attr or NewType extensions, the use cases are straightforward once you've read the brief docstrings. Error messages are handled by mypy itself, so you get the usual type-checking feedback. The main challenge is that documentation is minimal—mostly just type stubs and brief comments. You'll often need to reference mypy's documentation or look at real-world examples on GitHub to understand advanced features.
Debugging is rarely an issue since the package mostly provides primitive building blocks. When something goes wrong, it's usually a mypy configuration problem rather than a mypy-extensions issue. Community support exists primarily through mypy's channels, which are reasonably responsive.
Best for: Projects already using mypy that need extended type system features like TypedDict, Literal types, or Protocol definitions.
Avoid if: You're not using mypy for type checking or need runtime type validation instead of static analysis.
Essential typing utilities, minimal but does exactly what's needed
The DX is straightforward because these are simple type constructors that integrate seamlessly with mypy and other type checkers. IDE autocomplete works perfectly since these are just classes and decorators. Error messages come from mypy itself, not this package, so you get standard type checking feedback. Documentation is sparse but each utility is self-explanatory with clear docstrings.
The main friction point is knowing when you actually need this package versus stdlib typing. Many features have migrated to typing proper over Python versions, so you'll find yourself checking compatibility matrices. For modern Python 3.9+ projects, you might only need this as a transitive dependency through mypy itself.
Best for: Projects using mypy that need typing features not yet available in your target Python version's stdlib.
Avoid if: You're targeting only Python 3.9+ where most features are available in the standard typing module.
Sign in to write a review
Sign In