File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change 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+ ` ` `
Original file line number Diff line number Diff line change 11[metadata]
22name = flake8_assignment_expressions
3- version = 0 .0.0
3+ version = 1 .0.0
44description = A flake8 plugin that disallows assignment expressions
55long_description = file: README.md
66long_description_content_type = text/markdown
You can’t perform that action at this time.
0 commit comments