Registry / type-stubs / types-mypy-extensions

types-mypy-extensions

JSON →
library1.1.0.20260518pypypiunverified

This package provides static type checking stubs for the `mypy-extensions` library. It enables type checkers like Mypy to understand the types defined in `mypy-extensions`, such as `LiteralString`, `TypedDict`, and `NoReturn`, particularly when those features are not yet available in the standard `typing` module for the target Python version. The current version is 1.1.0.20260408, released as part of the `typeshed` project, with releases generally aligned with `typeshed` updates.

pip install types-mypy-extensions
INSTALL
IMPORT
SIG · TYPES-MYPY-EXTENSI
T
types-mypy-extensions
type-stubspythonv1.1.0.20260518
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0.20260518 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LiteralString
from mypy_extensions_stubs import LiteralString
from mypy_extensions_stubs import LiteralString

This example demonstrates how to use `LiteralString` from `mypy_extensions` to enforce type safety against non-literal strings. The `types-mypy-extensions` package provides the necessary type stubs for a type checker like Mypy to correctly analyze these type hints.

from mypy_extensions import LiteralString def process_query(query: LiteralString) -> None: print(f"Executing safe query: {query}") def get_user_input() -> str: # Simulate user input which is not guaranteed to be a literal string return 'SELECT * FROM users; DROP TABLE users;' # Malicious input # This is a safe literal string safe_query: LiteralString = "SELECT id, name FROM users WHERE active = TRUE;" process_query(safe_query) # If type checked by mypy (with types-mypy-extensions installed), # the following line is expected to fail because get_user_input() returns 'str', not 'LiteralString'. # mypy will detect the type mismatch, preventing potential SQL injection if 'query' was used directly. # Uncommenting the line below and running mypy should show a type error. # process_query(get_user_input()) print("Run 'mypy your_file.py' to see type checking results.")
Debug
Known issues
gotchaThis is a stub-only package. It provides type annotations for type checkers but does not contain any runtime code. You must install the actual 'mypy-extensions' package separately for your code to run successfully.
fix
To use the functionality, install the runtime package: `pip install mypy-extensions`.
affects: All versions
gotchaThe 'types-mypy-extensions' package itself requires Python >= 3.10 to install and use. This means your development/type-checking environment must run Python 3.10 or newer, even if your target runtime environment uses an older Python version with 'mypy-extensions'.
fix
Ensure your environment for running type checkers (e.g., `mypy`) is Python 3.10 or newer.
affects: All versions
gotchaMany features provided by 'mypy-extensions' (e.g., TypedDict, NoReturn, LiteralString) are now part of the standard `typing` module in modern Python versions (e.g., TypedDict in 3.8+, NoReturn in 3.6+, LiteralString in 3.11+). Using `mypy-extensions` might be unnecessary or lead to confusion if your project primarily targets these newer Python versions.
fix
Consider using imports from the standard `typing` module if your target Python version supports it. For example, `from typing import LiteralString` instead of `from mypy_extensions import LiteralString` for Python 3.11+.
affects: All versions when used with Python 3.6+
Upgrade
Version history
1.1.0.20260518latest on PyPI · released May 18, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
types-mypy-extensions — pip install types-mypy-extensions · libregistry