types-commonmark provides official typing stubs for the `commonmark` Python library, enabling static type checkers like MyPy and Pyright to analyze `commonmark` code with full type information. This package is part of the `typeshed` project. The current version is 0.9.2.20250330, with releases typically tied to `commonmark` updates or `typeshed` maintenance cycles.
pip install types-commonmarkVerified import paths — ran on the pinned version, not inferred.
To leverage `types-commonmark`, install both `commonmark` and `types-commonmark`. Your type checker (e.g., MyPy) will automatically use the installed stubs to provide type safety and auto-completion for `commonmark` functions and classes. The example demonstrates typical `commonmark` usage where `types-commonmark` adds static type checking benefits without changing the runtime code. Run this code with `commonmark` installed, then run a type checker like `mypy` on the file to see the stubs in action.
Import objects from the actual `commonmark` library (e.g., `from commonmark import Parser`). `types-commonmark` works in the background with your type checker.
Keep both `commonmark` and `types-commonmark` updated, or verify compatibility. `typeshed` stub versions are often aligned with the runtime library's major version to indicate compatibility.
Set up a `pyproject.toml` or `mypy.ini` file and integrate a type checker into your development workflow.