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.
Prefix inheritance is disabled by default. Set
--tyrant-inherit-layers-from-module-prefixes=y to let underscore-qualified
modules inherit the layer of their longest declared module-name prefix. For
example, bbb_unit_test.py and bbb_integration_test.py then inherit the layer
declared by @module bbb, so they do not need to be listed separately and
cannot import higher layers. Qualified entry modules such as
__init___unit_test.py inherit the entry layer, and qualified configured
shared modules such as types_unit_test.py inherit the shared layer.
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
Add --tyrant-inherit-layers-from-module-prefixes=y to that command only when
prefix inheritance is wanted.
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.5.1.tar.gz.
File metadata
- Download URL: pylint_tyrant-0.5.1.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0e322c9407740c56886cfcab70ab85fb1433576944c94f78cfea62ec3ed3581
|
|
| MD5 |
1f705a41549e15d6927df68b7918a8ee
|
|
| BLAKE2b-256 |
718f6fdedc97d748525c3ce4c47f2bff287c7eb36fbe0eb35cf2001048bfd21c
|
Provenance
The following attestation bundles were made for pylint_tyrant-0.5.1.tar.gz:
Publisher:
publish.yml on otakutyrant/tyrant-rules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylint_tyrant-0.5.1.tar.gz -
Subject digest:
a0e322c9407740c56886cfcab70ab85fb1433576944c94f78cfea62ec3ed3581 - Sigstore transparency entry: 1745308665
- Sigstore integration time:
-
Permalink:
otakutyrant/tyrant-rules@7dbcce9e6c155c0d3e5e9b2be68797b44c907bb0 -
Branch / Tag:
refs/tags/pylint-tyrant-v0.5.1 - Owner: https://github.com/otakutyrant
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7dbcce9e6c155c0d3e5e9b2be68797b44c907bb0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pylint_tyrant-0.5.1-py3-none-any.whl.
File metadata
- Download URL: pylint_tyrant-0.5.1-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6ea9dc18f0fc11904a890220ad6c55d39e8e9ce26b55d608cbc845d07781464
|
|
| MD5 |
893fd7b31a209bd26ae83fc63bbf41d9
|
|
| BLAKE2b-256 |
fa4c3d0f0bc0828e273f2946d87f05f6c5bf89f42fe2d55369e03561a9f0309f
|
Provenance
The following attestation bundles were made for pylint_tyrant-0.5.1-py3-none-any.whl:
Publisher:
publish.yml on otakutyrant/tyrant-rules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylint_tyrant-0.5.1-py3-none-any.whl -
Subject digest:
f6ea9dc18f0fc11904a890220ad6c55d39e8e9ce26b55d608cbc845d07781464 - Sigstore transparency entry: 1745308763
- Sigstore integration time:
-
Permalink:
otakutyrant/tyrant-rules@7dbcce9e6c155c0d3e5e9b2be68797b44c907bb0 -
Branch / Tag:
refs/tags/pylint-tyrant-v0.5.1 - Owner: https://github.com/otakutyrant
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7dbcce9e6c155c0d3e5e9b2be68797b44c907bb0 -
Trigger Event:
push
-
Statement type: