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.0.tar.gz (11.6 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.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pylint_tyrant-0.3.0.tar.gz
  • Upload date:
  • Size: 11.6 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.0.tar.gz
Algorithm Hash digest
SHA256 dcb6264194a60f8f2e68e074a6e4ca16be63d44458b9b9de876fd62e88a98e72
MD5 83cf234167e7d918dc2b020fb44a25df
BLAKE2b-256 f43cf94912a3238efa686b6b9087c048fb9dd442b748dc855d68b7e326f7399d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pylint_tyrant-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c8311c25be6da091b68784b6c7ec7c113da5a766550062ffe49b434142479e9
MD5 45cb7af1b55cbb01c6a36f3fbe446b51
BLAKE2b-256 9e59e375f8d3c36953f2e5dd5fb83ec6ea68f7024b33e16306621576c0717900

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