Registry / type-stubs / types-commonmark

types-commonmark

JSON →
library0.9.2.20250330pypypiunverified

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-commonmark
INSTALL
IMPORT
SIG · TYPES-COMMONMARK
T
types-commonmark
type-stubspythonv0.9.2.20250330
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 v0.9.2.20250330 · 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 · 18.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

No direct runtime imports
N/A - `types-commonmark` provides type stubs for static analysis, not runtime code.
from types_commonmark import SomeClass
Typing stubs from `typeshed` (`types-*` packages) are used by static type checkers (e.g., MyPy, Pyright) at design/build time to provide type hints for the corresponding runtime library (e.g., `commonmark`). They do not expose any objects for direct import or runtime execution.

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 commonmark from commonmark.node import Node def process_markdown(text: str) -> str: """Parses markdown and renders it to HTML.""" parser = commonmark.Parser() renderer = commonmark.HtmlRenderer() # The type checker (e.g., MyPy) will use types-commonmark # to understand that 'root_node' is a Node object, and 'render' returns str. root_node: Node = parser.parse(text) html_output: str = renderer.render(root_node) return html_output markdown_text = "# Hello, Markdown!\n\nThis is some *formatted* text." html = process_markdown(markdown_text) print(html) # Expected output (simplified example based on commonmark rendering): # <h1>Hello, Markdown!</h1> # <p>This is some <em>formatted</em> text.</p>
Debug
Known issues
gotcha`types-commonmark` provides type stubs for static analysis only; it does not contain runtime code. Attempting to import objects directly from `types_commonmark` will result in a `ModuleNotFoundError`.
fix
Import objects from the actual `commonmark` library (e.g., `from commonmark import Parser`). `types-commonmark` works in the background with your type checker.
affects: All
gotchaEnsure that the version of `types-commonmark` is compatible with your installed `commonmark` library version. Mismatched versions can lead to incorrect or missing type hints, or even runtime errors if `commonmark` APIs change significantly.
fix
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.
affects: All
gotchaAfter installing `types-commonmark`, you need a static type checker (e.g., MyPy, Pyright, or Ruff's type checking rules) configured in your project to actually benefit from the type stubs. Without a type checker, the stubs have no effect.
fix
Set up a `pyproject.toml` or `mypy.ini` file and integrate a type checker into your development workflow.
affects: All
Upgrade
Version history
0.9.2.20250330latest on PyPI · released Mar 29, 2025
Audit
Dependencies
commonmarkrequiredThe runtime library for which these stubs provide type information. While not a hard runtime dependency for `types-commonmark` itself, the stubs are useless without the `commonmark` library.
Agent activity
16 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
types-commonmark — pip install types-commonmark · libregistry