Skip to main content

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-order
  • tyrant-no-direct-error-instantiation
  • tyrant-require-docstring-for-public-api
  • tyrant-require-module-docstring
  • tyrant-require-empty-line-after-module-docstring
  • tyrant-require-package-init-module-organization-docstring
  • tyrant-prefer-single-line-docstring
  • tyrant-enforce-module-layer-dependencies
  • tyrant-restrict-relative-imports-to-base-module

tyrant-enforce-module-layer-dependencies

Requires configured project directories and package-local module layers to depend only on themselves or lower layers.

Project-layer mode uses --tyrant-layers:

pylint \
  --load-plugins=pylint_tyrant \
  --enable=tyrant-enforce-module-layer-dependencies \
  --tyrant-layers=lib,services,app \
  path/to/your_package

Package-local mode uses --tyrant-shared-modules. In this mode, __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. Imports may only go downward: entry -> feature/shared, feature -> feature/shared, shared -> shared.

pylint \
  --load-plugins=pylint_tyrant \
  --enable=tyrant-enforce-module-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

pylint_tyrant-0.3.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylint_tyrant-0.3.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file pylint_tyrant-0.3.1.tar.gz.

File metadata

  • Download URL: pylint_tyrant-0.3.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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

Hashes for pylint_tyrant-0.3.1.tar.gz
Algorithm Hash digest
SHA256 dbc85c9169d4e7a910c4db1b789c3e7e1535c4936d1ba3a9c450505ed94293cf
MD5 699d8b757f8add3f384bdc9be78e9df7
BLAKE2b-256 8710af94220abd4480a562935c95363f20ab28936865c7e73ee5c275293e0961

See more details on using hashes here.

File details

Details for the file pylint_tyrant-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pylint_tyrant-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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

Hashes for pylint_tyrant-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 be563d4513c9fcda60a3a50a8e3d98fd23764bd5ce512661ffc66ce8e4b74aba
MD5 245f8120cc65c02e4bcb561b58138c56
BLAKE2b-256 6a824056e2992b8e5ce0fc2ae681d3911d2dadd9de12dd8c9804bbddf1d4d2f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page