A flake8 plugin that disallows assignment expressions.
pip install flake8_assignment_expressions
Code | Description |
---|---|
ASE101 | Line contains assignment expression |
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.")
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]