{"id":7824,"library":"types-mypy-extensions","title":"Typing Stubs for Mypy Extensions","description":"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.","status":"active","version":"1.1.0.20260408","language":"python","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","mypy","type-checking","typeshed"],"install":[{"cmd":"pip install types-mypy-extensions","lang":"bash","label":"Install types-mypy-extensions"}],"dependencies":[],"imports":[{"wrong":"from mypy_extensions_stubs import LiteralString","symbol":"LiteralString","correct":"from mypy_extensions_stubs import LiteralString"}],"quickstart":{"code":"from mypy_extensions import LiteralString\n\ndef process_query(query: LiteralString) -> None:\n    print(f\"Executing safe query: {query}\")\n\ndef get_user_input() -> str:\n    # Simulate user input which is not guaranteed to be a literal string\n    return 'SELECT * FROM users; DROP TABLE users;' # Malicious input\n\n# This is a safe literal string\nsafe_query: LiteralString = \"SELECT id, name FROM users WHERE active = TRUE;\"\nprocess_query(safe_query)\n\n# If type checked by mypy (with types-mypy-extensions installed),\n# the following line is expected to fail because get_user_input() returns 'str', not 'LiteralString'.\n# mypy will detect the type mismatch, preventing potential SQL injection if 'query' was used directly.\n# Uncommenting the line below and running mypy should show a type error.\n# process_query(get_user_input())\n\nprint(\"Run 'mypy your_file.py' to see type checking results.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"To use the functionality, install the runtime package: `pip install mypy-extensions`.","message":"This 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your environment for running type checkers (e.g., `mypy`) is Python 3.10 or newer.","message":"The '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'.","severity":"gotcha","affected_versions":"All 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+.","message":"Many 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.","severity":"gotcha","affected_versions":"All versions when used with Python 3.6+"}],"env_vars":null,"search_vec":"'1.1.0.20260408':62 'align':73 'avail':47 'check':11,82 'checker':22 'current':59 'defin':29 'enabl':20 'extens':5,17,33 'featur':43 'general':72 'librari':18 'like':23 'literalstr':36 'modul':52 'mypi':4,16,24,32,79 'mypy-extens':15,31 'noreturn':39 'packag':7 'part':65 'particular':40 'project':69 'provid':8 'python':56 'releas':63,71 'standard':50 'static':9 'stub':2,12,78 'target':55 'type':1,10,21,28,51,77,81 'type-check':80 'typeddict':37 'typesh':68,75,83 'understand':26 'updat':76 'version':57,60 'yet':46","created_at":"2026-04-16T14:14:58.073599+00:00","updated_at":"2026-04-16T14:14:58.073599+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nModuleNotFoundError: No module named 'mypy_extensions_stubs'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.1.0.20260518","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/typeshed-internal/stub_uploader","docs":null,"changelog":"https://github.com/typeshed-internal/stub_uploader/blob/main/data/changelogs/mypy-extensions.md","pypi":"https://pypi.org/project/types-mypy-extensions/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}