Flake type annotations plugin
The flake8 plugin checking for correct usage of the Python type annotations.
Use with flake8-annotations for even better results!
Installation
Plugin requires flake8 >3.0.0
pip install flake-type-annotations-plugin
Rules
TAN001
This rule disallows usage of Union and Optional type annotations and expects user
to use the new | operator syntax.
Example:
# WRONG
from typing import Optional, Union
def func(arg: Optional[int]) -> Union[int, str]: # violates TAN001
return arg if arg is not None else "N/A"
# CORRECT
def func(arg: int | None) -> int | str: # OK
return arg if arg is not None else "N/A"
For Python versions <3.10 a top-level module import
from __future__ import annotations must be included in order to use this
syntax.
More can be read in PEP604.
TAN002
This rule disallows usage of type annotations where built-in types can be used.
Example:
# WRONG
from typing import List, Tuple
def func(arg: Tuple[int]) -> List[int]: # violates TAN002
return list(arg)
# CORRECT
def func(arg: tuple[int]) -> list[int]: # OK
return list(arg)
For Python versions <3.9 a top-level module import
from __future__ import annotations must be included in order to use this
syntax.
More can be read in PEP585.
Metadata
Release files for flake-type-annotations-plugin 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| flake-type-annotations-plugin-0.2.0.tar.gz | 4.1 kB | Without provenance | Details |
Release files / flake-type-annotations-plugin-0.2.0.tar.gz
| Download URL | flake-type-annotations-plugin-0.2.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff840d48a722e330cb44167a021a7acc9a315b7b1bdb8707db84f9b0d4eb84f6
|
|
BLAKE2b-256 checksum How to use checksums |
9a90cd279b5deb4cbe2c7ba1f704ad8829a30c98778bf1f9ed4b5315ccad1106
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 CPython/3.10.7
|
Security for flake-type-annotations-plugin 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.