{"library":"types-markdown","title":"Typing Stubs for Python-Markdown","description":"types-markdown is a type stub package that provides static type annotations for the popular `markdown` library (Python-Markdown). It enables static type checkers like MyPy to validate code that uses the `markdown` library, improving code quality and catching potential errors before runtime. This package is automatically generated and released from the `typeshed` project and follows a versioning scheme tied to the `markdown` runtime library version.","status":"active","version":"3.10.2.20260211","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","markdown","type-checking","typeshed"],"install":[{"cmd":"pip install types-markdown","lang":"bash","label":"Install stubs"},{"cmd":"pip install markdown types-markdown","lang":"bash","label":"Install runtime and stubs"}],"dependencies":[{"reason":"This package provides type stubs for the 'markdown' runtime library. The 'markdown' library itself must be installed and used for any runtime functionality.","package":"markdown","optional":false}],"imports":[{"note":"Type stubs are not imported directly. You import from the runtime library (e.g., `markdown`) and type checkers will automatically use the installed stubs.","symbol":"markdown","correct":"import markdown"}],"quickstart":{"code":"import markdown\nfrom typing import TYPE_CHECKING\n\n# The actual Markdown library is imported for runtime use\n# types-markdown provides the type hints for this 'markdown' module\n\nmarkdown_text = \"\"\"\n# Hello, Markdown!\n\nThis is a **bold** paragraph with an [inline link](https://example.com).\n\n- List item 1\n- List item 2\n\"\"\"\n\n# Convert Markdown to HTML\nhtml_output: str = markdown.markdown(markdown_text)\n\nprint(html_output)\n\nif TYPE_CHECKING:\n    # Example of type checking a function from the markdown library\n    # This part only runs during type checking, not runtime\n    from markdown import Markdown\n    md_parser: Markdown = markdown.Markdown(extensions=['fenced_code'])\n    typed_html: str = md_parser.convert(markdown_text)\n    # The type checker would ensure 'convert' returns a string and 'Markdown' is correctly instantiated\n","lang":"python","description":"This quickstart demonstrates how to use the `markdown` library with the `types-markdown` stubs implicitly providing type hints. The `TYPE_CHECKING` block shows how type checkers benefit from the stubs, ensuring correct usage of the `markdown` library's API."},"warnings":[{"fix":"Ensure both `markdown` and `types-markdown` are installed in your environment: `pip install markdown types-markdown`.","message":"The `types-markdown` package contains only type stub files (`.pyi`) and no runtime code. You must install the actual `markdown` library (e.g., `pip install markdown`) to use its functionality. `types-markdown` is solely for static type checking.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review type checker errors after updating `types-markdown`. If encountering new errors, you may need to adjust your code to satisfy the more accurate type hints or temporarily pin to an older `types-markdown` version while addressing the issues. Typeshed provides versioning recommendations for stubs.","message":"Stub packages, including `types-markdown`, can introduce 'breaking changes' for type checkers even if the runtime library's API remains stable. This can happen due to stricter or more accurate types being added or corrected in `typeshed`, potentially revealing previously uncaught type errors in your codebase.","severity":"breaking","affected_versions":"All versions"},{"fix":"When managing dependencies, be explicit about the `types-markdown` version if you need to guarantee consistent type checking behavior, e.g., `types-markdown==3.10.2.20260211`.","message":"The versioning for `types-markdown` (e.g., `3.10.2.20260211`) indicates compatibility with the runtime `markdown` library. The `3.10.2` portion refers to the target runtime version (`markdown==3.10.2.*`), and the trailing date (`20260211`) is the stub's release date from Typeshed. For critical applications, consider pinning the stub package to a known good version.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}