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-enforce-project-layer-dependencies
  • tyrant-enforce-package-layer-dependencies
  • tyrant-no-direct-error-instantiation
  • tyrant-require-docstring-for-public-api
  • tyrant-require-module-docstring
  • tyrant-require-empty-line-after-module-docstring
  • tyrant-prefer-single-line-docstring
  • tyrant-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

pylint_tyrant-0.4.2.tar.gz (14.4 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.4.2-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

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

Hashes for pylint_tyrant-0.4.2.tar.gz
Algorithm Hash digest
SHA256 05ffbe5d36ef1b9ac492b2fb0443caacb0c80a8117234ac76a4193240d22c2ae
MD5 48cf00f803d529157d6ac93503b49d69
BLAKE2b-256 aba770fcd43ccaca55b361c46c7b1bf9222b9f872d194832b231fbe720cc921e

See more details on using hashes here.

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

Hashes for pylint_tyrant-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 590b7807f24a0fdfc4b419757f9f267695f5a636af56f67cc571db9f27c0d394
MD5 4d8ca85b8296c2473988ac41f7f1f6e2
BLAKE2b-256 d67c5bca4bd83419bc8daf05073b096805f8de5e1152973e47fad6a42da13cdb

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