Skip to content

Commit 10d0501

Browse files
author
Nermin Dedovic
committed
Added README
1 parent 692b9c4 commit 10d0501

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# flake8_expression_assignments
2+
3+
A flake8 plugin that disallows assignment expressions.
4+
5+
## Installation
6+
7+
`pip install flake8_assignment_expressions`
8+
9+
## Flake8 codes
10+
11+
| Code | Description |
12+
|--------|--------------------------------------------------------|
13+
| ASE101 | Line contains assignment expression |
14+
15+
## Why
16+
17+
Assignment expressions/the walrus operator was introduced in Python 3.8.
18+
If you want to keep assignment expressions out of your own or your companies'
19+
repositories, use this plugin.
20+
21+
This plugin will encourage you to rewrite code like
22+
23+
```python
24+
import os
25+
26+
if environment := os.getenv("ENVIRONMENT"):
27+
print(f"You are currently on the {environment} environment.")
28+
```
29+
30+
into
31+
32+
```python
33+
import os
34+
35+
environment = os.getenv("ENVIRONMENT")
36+
if environment:
37+
print(f"You are currently on the {environment} environment.")
38+
```
39+
40+
## Running as a pre-commit hook
41+
See [pre-commit](https://github.com/pre-commit/pre-commit) for instructions.
42+
43+
Sample `.pre-commit-config.yaml`:
44+
45+
```yaml
46+
- repo: https://github.com/pycqa/flake8
47+
rev: 4.0.1
48+
hooks:
49+
- id: flake8
50+
additional_dependencies: [flake8_assignment_expressions]
51+
```

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = flake8_assignment_expressions
3-
version = 0.0.0
3+
version = 1.0.0
44
description = A flake8 plugin that disallows assignment expressions
55
long_description = file: README.md
66
long_description_content_type = text/markdown

0 commit comments

Comments
 (0)