Skip to main content

Flake8 plugin that checks top-level caller/callee definition order

Project description

flake8-caller-callee-order

This repo includes a flake8 plugin that enforces top-level caller/callee definition order:

uv run flake8 path/to/file.py

For example, with the default callee-before-caller order, this is reported:

def main():
    helper()


def helper():
    print("helper")
CCO001 `main` calls `helper`, but `helper` is defined later at line 5

By default, caller-callee-order = callee-before-caller, and CCO001 is emitted when a top-level function calls another top-level function that is defined later in the same file. For now it only checks simple function calls like helper(); method and attribute calls like self.helper() or module.helper() are ignored. It only orders top-level def and async def functions; variables, classes, and other declarations are not checked yet.

To require callers before their callees instead, configure Flake8 with:

[flake8]
caller-callee-order = caller-before-callee

Development

uv run pytest
uv run ruff check
uv run ruff format
uv run mypy

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

flake8_caller_callee_order-0.1.0.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

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

flake8_caller_callee_order-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file flake8_caller_callee_order-0.1.0.tar.gz.

File metadata

File hashes

Hashes for flake8_caller_callee_order-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7bf5ae60733abf7ff4d923c3f420c06aa21206159a93e5bfb274f3ee52acf91
MD5 6ee27a61d5172fbe2f7c57ac292781ca
BLAKE2b-256 4c8199978bbe8a36e0913dec5e3f0cb8bd3cf6605490318f25a4cf0b0f6d4327

See more details on using hashes here.

File details

Details for the file flake8_caller_callee_order-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_caller_callee_order-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad68a19bc8baec0455442a6b6e4933a5d3a6da67403db7c4c2676b8e0ac05f89
MD5 e9a7a53fb09119bea966e98905e9dfac
BLAKE2b-256 39e0ec5e13f03c5e55997bd4b34e0e5e30e98418ce5035eb103e95accce3a559

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