A flake8 plugin that disallows assignment expressions
Project description
flake8_expression_assignments
A flake8 plugin that disallows assignment expressions.
Installation
pip install flake8_assignment_expressions
Flake8 codes
Code | Description |
---|---|
ASE101 | Line contains assignment expression |
Why
Assignment expressions/the walrus operator was introduced in Python 3.8. If you want to keep assignment expressions out of your own or your companies' repositories, use this plugin.
This plugin will encourage you to rewrite code like
import os
if environment := os.getenv("ENVIRONMENT"):
print(f"You are currently on the {environment} environment.")
into
import os
environment = os.getenv("ENVIRONMENT")
if environment:
print(f"You are currently on the {environment} environment.")
Running as a pre-commit hook
See pre-commit for instructions.
Sample .pre-commit-config.yaml
:
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [flake8_assignment_expressions]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8_assignment_expressions-1.0.0.tar.gz
.
File metadata
- Download URL: flake8_assignment_expressions-1.0.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c35dfc65da1b9a0535464bd08751aeaf3dde60ebc35bea0752edcac0a6ced7a |
|
MD5 | 7a8ab353c9286ec3dbaa13cc9ffef16c |
|
BLAKE2b-256 | 9ffadf3f277af3a8b8aba581fdba8e337c7486a6a7d3318caa0d097fbb51b4c2 |
File details
Details for the file flake8_assignment_expressions-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: flake8_assignment_expressions-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c23aca7273a97216e02d2e1a6e516c09c7b1f185df18eaa0effdcc3c58c4d6b4 |
|
MD5 | 9bcf707736bd8e6fd86b234b1b0630a2 |
|
BLAKE2b-256 | 50935da25f37dad8dd3f3ce3a1c5d704b71e79a36aeaa38bae1241125d3a0382 |