Skip to main content

Well, actually — an opinionated Python linter and formatter: bans else and elif, allows only flat ternaries, and enforces blank lines around return

Project description

actually

Well, actually, your code should read like this.

actually is a highly opinionated Python linter and formatter built on ast-grep. It enforces a guard-clause style:

  • else is banned — on if, and as the completion clause on for, while, and try alike
  • elif is banned
  • ternaries are allowed only flat — nested conditional expressions are banned
  • return needs a blank line above it when it follows other statements in its block
  • return needs a blank line below it when more code follows

Usage

uvx well-actually check src/
uvx well-actually format src/

Installed (uv tool install well-actually), the short command is available too:

actually check src/
actually format src/

check reports violations and exits non-zero when it finds any. Both commands lint .py files only; directory scans skip environment, cache, and VCS directories (.venv, venv, .git, __pycache__, node_modules, and friends) and respect .gitignore files — nested ones and negations included, matched via pathspec (black's approach), so no git installation is required. When a .git directory is found above the scanned path, .gitignore files up to that repo root apply as well. Global excludes (core.excludesFile, .git/info/exclude) are not consulted. A .py file passed explicitly is always linted.

format rewrites files in place, then reports what it could not fix:

  • inserts the missing blank lines around return
  • dedents a try/except/else completion clause into straight-line code when every except body already exits (return, raise, continue, break) — when one falls through, the rewrite would change behaviour, so it is reported for human refactoring instead

Example

def describe_config(path):
    try:
        config = parse_json_file(path)
    except ParseError:
        return "invalid config"
    else:
        return describe(config)

actually format rewrites this to:

def describe_config(path):
    try:
        config = parse_json_file(path)
    except ParseError:
        return "invalid config"

    return describe(config)

Development

uv sync
uv run pytest
uv run actually check src/ tests/

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

well_actually-0.2.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

well_actually-0.2.2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file well_actually-0.2.2.tar.gz.

File metadata

  • Download URL: well_actually-0.2.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for well_actually-0.2.2.tar.gz
Algorithm Hash digest
SHA256 144f0987163182ffed6bc8bc7c9b6aa01e05b12e1cde5a06dd335d26b78dcab2
MD5 e18623cf514d036ac9c5b94bb5e44a13
BLAKE2b-256 97d0b5ae4de19d03e09f1f2d39a3f5c5dcb1944379a8615662c368a89077ec76

See more details on using hashes here.

File details

Details for the file well_actually-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: well_actually-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for well_actually-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aeacd5e3c7b52cba4049a076e4a7ba5fb62133dc2cd48c98d09710d1daa485d0
MD5 97229485b19deb5916aa2536e3ca39df
BLAKE2b-256 d02f8bf02f0a0109996287219ccb65d45d2fc0718eb99699ab680d2ebb3f0f2d

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