Skip to main content

auto-walrus

auto-walrus

auto-walrus

Build Status Coverage pre-commit.ci status

A tool and pre-commit hook to automatically apply the awesome walrus operator.

Installation

pip install auto-walrus

Usage as a pre-commit hook

See pre-commit for instructions

Sample .pre-commit-config.yaml:

-   repo: https://github.com/MarcoGorelli/auto-walrus
    rev: 0.4.1
    hooks:
    -   id: auto-walrus

Command-line example

auto-walrus myfile.py
-    n = 10
-    if n > 3:
+    if (n := 10) > 3:
         print(n)

Configuration

Using the walrus operator can result in longer lines. Lines longer than what you pass to --line-length won't be rewritten to use walrus operators.

E.g.

auto-walrus myfile_1.py myfile_2.py --line-length 89

Lines with comments won't be rewritten.

Used by

To my great surprise, this is being used by:

Anyone else? Please let me know, or you can open a pull request to add yourself.

Testimonials

Christopher Redwine, Senior Software Engineer at TechnologyAdvice

hmm, i dunno about this one chief

Michael Kennedy & Brian Okken, hosts of the Python Bytes podcast:

I kind of like this being separate from other tools

Someone on Discord

you're a monster

Will McGugan, CEO / Founder of http://Textualize.io:

Embrace the Walrus!

Credits

Logo by lion_space

Release files for auto-walrus 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for auto-walrus 0.4.1
File Size Uploaded
auto_walrus-0.4.1.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for auto-walrus 0.4.1
File Interpreter ABI Platform
auto_walrus-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / auto_walrus-0.4.1.tar.gz

Download URL auto_walrus-0.4.1.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9874ab07597dc2cc78a30fca944f6a9e6bee0033645e659ac9337a219691662f
BLAKE2b-256 checksum
How to use checksums
97529a7484513537f4c469ecbef28be339e364f3b3da116a5ad6078af27b59b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

Release files / auto_walrus-0.4.1-py3-none-any.whl

Download URL auto_walrus-0.4.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53bda8558708dcd67b2205212acafec7c12543dec0bd7f84f9f2207f4b6e6d52
BLAKE2b-256 checksum
How to use checksums
1e959ee7a9e668f47395a431514543d6a8a452998415738b48c92cc9edf14c57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page