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.

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.1.0.tar.gz (5.7 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.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: well_actually-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for well_actually-0.1.0.tar.gz
Algorithm Hash digest
SHA256 805d0f6ccac53eaa9b0f17d6f0868aebd2fa07b7e889c206ae2d0c366df6838d
MD5 57196995e8ab5ff48084bc83123a171f
BLAKE2b-256 9fa387d69d713a0902710eab7f2ac30f471e249505eee980f6353a0f667ded53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: well_actually-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for well_actually-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5849b70a7dbf67d2d31d78f537ce1cfdf4075d0520031282982350ee82b87993
MD5 89752b806514f020b0e0089ce0a3252a
BLAKE2b-256 fd308067f59fe3478130aa3cc3ef353dfd9506825896817a70262f1babdc9987

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