Registry / serialization / docstring-parser

docstring-parser

JSON →
library0.18.0pypypi✓ verified 26d ago

A Python library for parsing docstrings in reST, Google, and Numpydoc formats. Current version: 0.17.0, released on July 21, 2025. Maintained with a stable release cadence.

pip install docstring-parser
INSTALL
IMPORT
SIG · DOCSTRING-PARSER
D
docstring-parser
serializationpythonv0.18.0
Install
1.6s avg
Import
42ms
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.18.0 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.044s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.040s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

parse
from docstring_parser import parse
Ensure correct import path to access the 'parse' function.

A quickstart guide demonstrating how to parse a sample docstring using the 'parse' function from docstring_parser.

from docstring_parser import parse # Sample docstring docstring = """ This is a sample function. :param x: The input value :type x: int :return: The squared value of x :rtype: int """ # Parse the docstring parsed = parse(docstring) # Access parsed components print(f"Description: {parsed.short_description}") print(f"Parameters: {parsed.params}") print(f"Returns: {parsed.returns}")
Debug
Known issues
breakingIn version 0.17.0, the 'parse' function now requires the 'style' parameter to be explicitly set. Omitting it will raise a TypeError.
fix
Update function calls to include the 'style' parameter, e.g., 'parse(docstring, style=DocstringStyle.AUTO)'.
affects: 0.17.0
deprecatedThe 'parse_from_object' function is deprecated and will be removed in a future release. Use 'parse' with the appropriate style parameter instead.
fix
Replace calls to 'parse_from_object' with 'parse' and specify the 'style' parameter.
affects: 0.17.0
gotchaWhen parsing docstrings with the 'parse' function, ensure that the 'style' parameter matches the docstring format (e.g., 'reST', 'Google', 'Numpydoc') to avoid parsing errors.
fix
Always specify the correct 'style' parameter when calling 'parse'.
affects: 0.17.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'docstring_parser'
The 'docstring_parser' library has not been installed in the current Python environment.
fix
Install the library using pip: `pip install docstring-parser`
ImportError: cannot import name 'DocstringAttr' from 'docstring_parser.common'
This error typically occurs due to incompatible versions of `docstring-parser` or conflicts with a `docstring-parser-fork` package, where the expected class `DocstringAttr` may not exist or has been renamed in the installed version.
fix
Ensure only one version of `docstring-parser` (and no conflicting forks) is installed and that it's up to date. Uninstall conflicting packages and reinstall `docstring-parser`.
ValueError: not enough values to unpack (expected 2, got 1)
The docstring being parsed, particularly in Google style (e.g., in an `Args:` section), has a malformed entry where a colon (':') is expected but another character (like a hyphen '-') is found, causing the `split` operation to fail.
fix
Correct the docstring format to adhere strictly to the expected style, ensuring parameters are defined with a colon, e.g., `param_name: description`.
ValueError: Arg X in docstring not found in function signature
A parameter is documented in the function's docstring (e.g., using `@param` or `Args:`) but does not actually exist in the function's definition (its signature).
fix
Either add the missing parameter to the function's signature or remove its documentation from the docstring to match the actual function definition.
Upgrade
Version history
0.18.0latest on PyPI · released Apr 14, 2026
Audit
Dependencies
typingrequiredProvides type hints for Python 3.8 and earlier versions
Agent activity
9 hits · last 30 days
node
8
Resources
docstring-parser — pip install docstring-parser · libregistry