A Python docstring linter that checks arguments, returns, yields, and raises sections
Project description
pydoclint
A Python docstring linter to check whether a docstring's sections (arguments, returns, raises, ...) match the function signature or function implementation.
It runs really fast. In fact, it can be thousands of times faster than darglint (or its maintained fork darglint2).
Here is a comparison of linting time on some famous Python projects:
pydoclint | darglint | |
---|---|---|
numpy | 2.0 sec | 49 min 9 sec (1,475x slower) |
scikit-learn | 2.4 sec | 3 hr 5 min 33 sec (4,639x slower) |
Additionally, pydoclint can detect some quite a few style violations that darglint cannot.
Currently, pydoclint supports three docstring styles:
- The numpy stlyle
- The Google style
- The Sphinx style
Another note: this linter and pydocstyle serves complementary purposes. It is recommended that you use both together.
Table of Contents
1. Installation
pip install pydoclint
Note that pydoclint currently only supports Python 3.8 and above. (Python 3.7 support may be added if there are interests and requests.)
2. Usage
2.1. As a native command line tool
pydoclint <FILE_OR_FOLDER>
Replace <FILE_OR_FOLDER>
with the file/folder names you want, such as .
.
2.2. As a flake8 plugin
Once you install pydoclint you will have also installed flake8. Then you can run:
flake8 --select=DOC <FILE_OR_FOLDER>
If you don't include --select=DOC
in your command, flake8 will also run
other built-in flake8 linters on your code.
2.3. As a pre-commit hook
pydoclint is configured for pre-commit and can be
set up as a hook with the following .pre-commit-config.yaml
configuration:
- repo: https://github.com/jsh9/pydoclint
rev: <latest_tag>
hooks:
- id: pydoclint
args:
- "--config=pyproject.toml"
You will need to install pre-commit
and run pre-commit install
.
2.4. Native vs flake8
Should I use pydoclint as a native command line tool or a flake8 plugin? Here's comparison:
Pros | Cons | |
---|---|---|
Native tool | Slightly faster | No inline or project-wide omission support right now [*] |
flake8 plugin | Supports inline or project-wide omission | Slightly slower because other flake8 plugins are run together |
*) This feature may be added in the near future
2.5. How to configure pydoclint
Please read this page: How to configure pydoclint
2.6. How to ignore certain violations in flake8 mode
Please read this page: How to ignore certain violations
3. Style violation codes
pydoclint currently has 6 categories of style violation codes:
DOC0xx
: Docstring parsing issuesDOC1xx
: Violations about input argumentsDOC2xx
: Violations about return argument(s)DOC3xx
: Violations about class docstring and class constructorDOC4xx
: Violations about "yield" statementsDOC5xx
: Violations about "raise" statements
For detailed explanations of each violation code, please read this page: pydoclint style violation codes.
4. Notes for users
If you'd like to use pydoclint for your project, it is recommended that you read these additional notes here.
5. Notes for developers
If you'd like to contribute to the code base of pydoclint, thank you!
This guide can hopefully help you get familiar with the code base faster.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pydoclint-0.2.2.tar.gz
.
File metadata
- Download URL: pydoclint-0.2.2.tar.gz
- Upload date:
- Size: 36.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a00ab0828405133495271a4b8ffe21ed3cc2bfde9cd2827041d5ca6a90b98f23 |
|
MD5 | 6683eb07e974355ad22b48c4fc533b75 |
|
BLAKE2b-256 | f05fce2590c9d9222c931542664efbb1e2d77c359aaf03b89e603675ac23cd8d |
File details
Details for the file pydoclint-0.2.2-py2.py3-none-any.whl
.
File metadata
- Download URL: pydoclint-0.2.2-py2.py3-none-any.whl
- Upload date:
- Size: 35.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb3daad23f43f12ea7ce7c8aa195a3a51e332c09367bf7b9f019dbb08a1272c6 |
|
MD5 | bf0dcd7009e884e0c96652502d589bf9 |
|
BLAKE2b-256 | 2965ebf820ad351199a6f5dcbcf962c20e8fd95284ad7556df80497d5c14bc59 |