A flake8 extension that checks for type annotations complexity
Project description
flake8-annotations-complexity
An extension for flake8 to report on too complex type annotations.
Complex type annotations often means bad annotations usage, wrong code decomposition or improper data structure choice. They are also hard to read and make code look java-like.
Annotation complexity is maximum annotation nesting level.
So List[int]
complexity is 2 and Tuple[List[Optional[str]], int]
is 4.
Default max annotation complexity is 3 and can be configured
via --max-annotations-complexity
option.
Installation
pip install flake8-annotations-complexity
Example
Sample file:
# test.py
def foo() -> List[int]:
return [1]
Usage:
$ flake8 --max-annotations-complexity=1 test.py
test.py:4:14: TAE002 too complex annotation (2 > 1)
Contributing
We would love you to contribute to our project. It's simple:
- Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
- Create a pull request. Make sure all checks are green.
- Fix review comments if any.
- Be awesome.
Here are useful tips:
- You can run all checks and tests with
make check
. Please do it before CI does. - We use BestDoctor python styleguide.
- We respect Django CoC. Make soft, not bullshit.
Project details
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_annotations_complexity-0.0.8.tar.gz
.
File metadata
- Download URL: flake8_annotations_complexity-0.0.8.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8914e76e31672c4063c928b0a250db6b935a16d1799de10457958a71d11bb665 |
|
MD5 | c2267c45daeb1e451ebd8c5f3b03f73a |
|
BLAKE2b-256 | d02295d82ddf351f3b0fe84fad532798d36797be0fb29d593b403740fe30dacc |
File details
Details for the file flake8_annotations_complexity-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: flake8_annotations_complexity-0.0.8-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44e299dac0ab64f3af4b478fac7feb635c113a606036de8b39dadab3531da7ed |
|
MD5 | 20f7d38513977a4b8573008ae993b2e4 |
|
BLAKE2b-256 | 860f5fc1850490364aa4f16d1fce3c5727b09c579332ba90d3fbf4e017196e0f |