Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MarcoGorelli/auto-walrus
Automatically use the awesome walrus operator
https://github.com/MarcoGorelli/auto-walrus
formatting linting python walrus-operator
Last synced: 15 days ago
JSON representation
Automatically use the awesome walrus operator
- Host: GitHub
- URL: https://github.com/MarcoGorelli/auto-walrus
- Owner: MarcoGorelli
- License: mit
- Created: 2022-10-07T09:39:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T21:42:06.000Z (23 days ago)
- Last Synced: 2024-10-22T17:22:26.938Z (22 days ago)
- Topics: formatting, linting, python, walrus-operator
- Language: Python
- Homepage:
- Size: 149 KB
- Stars: 107
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-python-code-formatters - auto-walrus
README
auto-walrus
auto-walrus
===========
[![Build Status](https://github.com/MarcoGorelli/auto-walrus/workflows/tox/badge.svg)](https://github.com/MarcoGorelli/auto-walrus/actions?workflow=tox)
[![Coverage](https://codecov.io/gh/MarcoGorelli/auto-walrus/branch/main/graph/badge.svg)](https://codecov.io/gh/MarcoGorelli/auto-walrus)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/MarcoGorelli/auto-walrus/main.svg)](https://results.pre-commit.ci/latest/github/MarcoGorelli/auto-walrus/main)A tool and pre-commit hook to automatically apply the awesome walrus operator.
## Installation
```console
pip install auto-walrus
```## Usage as a pre-commit hook
See [pre-commit](https://github.com/pre-commit/pre-commit) for instructions
Sample `.pre-commit-config.yaml`:
```yaml
- repo: https://github.com/MarcoGorelli/auto-walrus
rev: 0.3.4
hooks:
- id: auto-walrus
```## Command-line example
```console
auto-walrus myfile.py
``````diff
- 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:
- https://github.com/python-graphblas/python-graphblas
- https://github.com/Remi-Gau/bids2cite
- https://github.com/TheAlgorithms/Python
- https://github.com/apache/supersetAnyone else? Please let me know, or you can open a pull request to add yourself.
## Testimonials
**Christopher Redwine**, [Senior Software Engineer at TechnologyAdvice](https://github.com/chrisRedwine)
> hmm, i dunno about this one chief
**Michael Kennedy & Brian Okken**, [hosts of the Python Bytes podcast](https://pythonbytes.fm/):
> 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](https://www.willmcgugan.com/):
> Embrace the Walrus!
## Credits
Logo by [lion_space](https://www.fiverr.com/lion_space)