Registry / type-stubs / docutils-stubs

docutils-stubs

JSON →
library0.0.22pypypi✓ verified 85d ago

docutils-stubs provides PEP 561 type stubs for the docutils library, enabling static type checking tools like MyPy to verify code that uses docutils. It helps catch type-related errors before runtime. The current version is 0.0.22, with releases typically following updates to the underlying docutils library or bug fixes.

pip install docutils-stubs
INSTALL
IMPORT
SIG · DOCUTILS-STUBS
D
docutils-stubs
type-stubspythonv0.0.22
Install
1.9s avg
Import
103ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.22 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.107s · 22.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.9s · import 0.099s · 23MB
21MB installed
● package 21MB
Code
Verified usage

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

publish_string
from docutils.core import publish_string
from docutils_stubs.core import publish_string
Stub packages like docutils-stubs provide type information for the original library; you should always import directly from 'docutils', not 'docutils_stubs'.
RSTParser
from docutils.parsers.rst import Parser as RSTParser
from docutils_stubs.parsers.rst import Parser as RSTParser
As with all stub packages, imports should target the original 'docutils' library for both runtime and type-checking purposes.

This example demonstrates how to use `docutils.core.publish_string` to convert reStructuredText to HTML. When `docutils-stubs` is installed alongside `docutils`, type checkers like MyPy will be able to provide accurate type analysis for calls to `publish_string` and other docutils functions, even though the import statement targets `docutils` directly.

from docutils.core import publish_string rst_content = """ My Document =========== This is a paragraph. * A list item * Another item """ # docutils-stubs provides type hints for this call html_output = publish_string( source=rst_content, writer_name='html' ) print(html_output[:100] + '...') # Print a snippet of the generated HTML
Debug
Known issues
gotchaInstalling `docutils-stubs` does NOT install `docutils`. You must install `docutils` separately for your code to run.
fix
Ensure both `docutils` and `docutils-stubs` are in your environment: `pip install docutils docutils-stubs`.
affects: All versions
gotchaDo not import directly from `docutils_stubs`. Stub packages are meant for type checkers, not for runtime imports.
fix
Always import symbols from the original `docutils` package (e.g., `from docutils.core import publish_string`). The type checker will automatically pick up the stubs.
affects: All versions
gotchaType stubs might occasionally lag behind the `docutils` library itself. If you're using a very new feature or a pre-release version of `docutils`, the stubs might not yet include type information for it.
fix
Check the `docutils-stubs` GitHub repository for updates or open an issue if you encounter missing types for stable `docutils` features.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'docutils'
You have installed `docutils-stubs` but not the actual `docutils` library.
fix
Run `pip install docutils` in addition to `pip install docutils-stubs`.
ImportError: cannot import name 'publish_string' from 'docutils_stubs.core'
Attempting to import directly from the stub package `docutils_stubs` instead of the original `docutils` library.
fix
Change your import statement to `from docutils.core import publish_string`. Stub packages are not meant for runtime imports.
error: Module 'docutils.core' has no attribute 'missing_function' [attr-defined]
The `docutils-stubs` package might be outdated or does not include type information for a specific, potentially new or non-standard, attribute/function in `docutils`.
fix
Ensure both `docutils` and `docutils-stubs` are up-to-date (`pip install --upgrade docutils docutils-stubs`). If the issue persists for a standard feature, consider reporting it on the `docutils-stubs` GitHub page.
Upgrade
Version history
0.0.22latest on PyPI · released Jan 2, 2022
Audit
Dependencies
docutilsrequiredProvides type hints for this package; docutils itself must be installed for runtime execution.
Agent activity
35 hits · last 30 days
node
30
OpenAI (training)
1
Resources
docutils-stubs — pip install docutils-stubs · libregistry