Pylint plugin with documentation and architecture rules.
Project description
pylint-tyrant
Pylint plugin with documentation and architecture rules inspired by
eslint-plugin-tyrant.
The plugin currently ships these rules:
tyrant-enforce-doc-tag-ordertyrant-enforce-project-layer-dependenciestyrant-enforce-package-layer-dependenciestyrant-no-direct-error-instantiationtyrant-require-docstring-for-public-apityrant-require-module-docstringtyrant-require-empty-line-after-module-docstringtyrant-prefer-single-line-docstringtyrant-restrict-relative-imports-to-base-module
tyrant-enforce-project-layer-dependencies
Requires configured project directories to depend only on themselves or lower layers.
This rule uses --tyrant-layers:
pylint \
--load-plugins=pylint_tyrant \
--enable=tyrant-enforce-project-layer-dependencies \
--tyrant-layers=lib,services,app \
path/to/your_package
tyrant-enforce-package-layer-dependencies
Requires same-package module layers to be declared in the entry-module docstring and to depend only on themselves or lower layers.
This rule uses --tyrant-shared-modules. __init__.py is treated as the entry module automatically, configured same-directory module names such as base or types.py are treated as shared low-level modules, and every other module in the directory is treated as a feature module.
Use @module for one ordered module layer and @module-group for one ordered flat peer layer:
"""Package docs.
@module materials - Core data.
@module-group paragraphs, lexicons - Peer modules derived from the same inputs.
@module metrics - Aggregates.
"""
Every feature module must be listed exactly once. Missing modules, extra listed modules, repeated modules, and upward imports are violations.
Every @module and @module-group tag must also include a non-empty relationship description.
pylint \
--load-plugins=pylint_tyrant \
--enable=tyrant-enforce-package-layer-dependencies \
--tyrant-shared-modules=base,types.py \
path/to/your_package
tyrant-require-docstring-for-public-api
Requires public classes, functions, and methods to have docstrings.
This rule currently treats names that do not start with _ as public. It checks:
- top-level public classes
- top-level public functions
- public methods on public classes
Valid:
class UserService:
"""Load users."""
def load_user(self) -> None:
"""Load one user."""
Also valid:
def load_user() -> None:
"""Load one user."""
Invalid:
def load_user() -> None:
pass
tyrant-enforce-doc-tag-order
Requires recognized docstring tags to follow one configured order.
This rule reads tags written as @tag - value from module, class, and function docstrings. It only checks tags listed in tyrant-doc-tag-order.
Configure it in pyproject.toml like this:
[tool.pylint.main]
load-plugins = ["pylint_tyrant"]
[tool.pylint."messages control"]
enable = ["tyrant-enforce-doc-tag-order"]
[tool.pylint.tyrant-doc-tag-order]
tyrant-doc-tag-order = ["@remarks", "@param", "@returns"]
Command-line equivalent:
pylint \
--load-plugins=pylint_tyrant \
--enable=tyrant-enforce-doc-tag-order \
--tyrant-doc-tag-order=@remarks,@param,@returns \
path/to/your_package
Valid:
def load_user() -> User:
"""Load one user.
@remarks - Used by the public API.
@param - User id.
@returns - Loaded user.
"""
Invalid:
def load_user() -> User:
"""Load one user.
@returns - Loaded user.
@param - User id.
"""
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylint_tyrant-0.4.2.tar.gz.
File metadata
- Download URL: pylint_tyrant-0.4.2.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05ffbe5d36ef1b9ac492b2fb0443caacb0c80a8117234ac76a4193240d22c2ae
|
|
| MD5 |
48cf00f803d529157d6ac93503b49d69
|
|
| BLAKE2b-256 |
aba770fcd43ccaca55b361c46c7b1bf9222b9f872d194832b231fbe720cc921e
|
File details
Details for the file pylint_tyrant-0.4.2-py3-none-any.whl.
File metadata
- Download URL: pylint_tyrant-0.4.2-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
590b7807f24a0fdfc4b419757f9f267695f5a636af56f67cc571db9f27c0d394
|
|
| MD5 |
4d8ca85b8296c2473988ac41f7f1f6e2
|
|
| BLAKE2b-256 |
d67c5bca4bd83419bc8daf05073b096805f8de5e1152973e47fad6a42da13cdb
|