Pydocstringformatter
A tool to automatically format Python docstrings to follow recommendations from
PEP 8 and
PEP 257 (or other supported style
guides.)
See What it does for currently supported auto-formatting.
Rationale
This project is heavily inspired by
docformatter.
When this project was started docformatter did not meet all of the requirements the
pylint project had for its docstring formatter and
was no longer actively maintained (this has changed since then). Therefore, some
contributors of pylint got together and started working on our own formatter to
fulfill our needs.
When asked we defined the objective of the tool as:
"A docstring formatter that follows PEP8 and PEP257 but makes some of the more 'controversial' elements of the PEPs optional"
See the original answer.
As such, the biggest difference between the two is that pydocstringformatter fixes
some of the open issues we found in docformatter. In general, the output of both
formatters (and any other docstring formatter) should be relatively similar.
How to install
pip install pydocstringformatter
Usage
Click here for a
full Usage overview.
Configuration
Pydocstringformatter will also read any configuration added to the
[tool.pydocstringformatter] section of a pyproject.toml file.
For example:
[tool.pydocstringformatter]
write = true
exclude = "**/my_dir/**,**/my_other_dir/**"
# Or:
exclude = ["**/my_dir/**", "**/my_other_dir/**"]
strip-whitespaces = true
split-summary-body = false
numpydoc-section-hyphen-length = false
Style
Pydocstringformatter can be configured to use a specific style. The default is pep257
but we support other styles as well. These can also be used at the same time. For
example with:
pydocstringformatter --style=pep257 --style=numpydoc myfile.py
Pre-commit
Pydocstringformatter can also be used as a pre-commit hook.
Add the following to your .pre-commit-config.yaml file:
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: SPECIFY VERSION HERE
hooks:
- id: pydocstringformatter
What it does
The following examples show some of the changes pydocstringformatter will apply. For a
full overview of all potential changes you can check out the
Usage page which
shows an up to date list of all formatters and their description.
# Bad
'''
my docstring'''
""" my
multi-line docstring """
"""my title
===========
my docstring
"""
# Good
"""My docstring."""
"""My
multi-line docstring.
"""
"""My title
===========
My docstring
"""
# With --summary-quotes-same-line
# Bad
"""
My
multi-line docstring
"""
# Good
"""My
multi-line docstring
"""
Development
For development and contributing guidelines please see
Development.
Release files for pydocstringformatter 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydocstringformatter-1.0.0.tar.gz | 29.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydocstringformatter-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 59.7 kB
Release files / pydocstringformatter-1.0.0.tar.gz
| Download URL | pydocstringformatter-1.0.0.tar.gz |
|---|---|
| Size | 29.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c2bc5e200ff118feab96c204b1f69ddb604832e177b26b598939e0e6913dcd0
|
|
BLAKE2b-256 checksum How to use checksums |
0fc9435887301c667ddcf1ed524ba82ff0998c280077f4987da6f3f72cb43778
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 4, 2026.
Transparency logRelease files / pydocstringformatter-1.0.0-py3-none-any.whl
| Download URL | pydocstringformatter-1.0.0-py3-none-any.whl |
|---|---|
| Size | 30.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f625f91798b14ee7c4fc8e1628c2d040390e32efa76f05ef14838e9bc2d1724
|
|
BLAKE2b-256 checksum How to use checksums |
2dee8acba0b2f928bd046ce06eef9c8f0450a3c25711f17b8362e6ed9b473da7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 4, 2026.
Transparency log