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.
pip install types-markdownVerified import paths — ran on the pinned version, not inferred.
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.
Ensure both `markdown` and `types-markdown` are installed in your environment: `pip install markdown types-markdown`.
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.
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`.