flake8-future-annotations
Verifies python 3.7+ files use from __future__ import annotations if a type is used in the module that can be rewritten using PEP 563.
Pairs well with pyupgrade with the --py37-plus flag or higher, since pyupgrade only replaces type annotations with the PEP 563 rules if from __future__ import annotations is present.
flake8 codes
| Code | Description |
|---|---|
| FA100 | Missing import if a type used in the module can be rewritten using PEP563 |
| FA101 | Missing import when no rewrite using PEP563 is available (see config) |
| FA102 | Missing import when code uses simplified types (list, dict, set, etc) |
Example
import typing as t
from typing import List
def function(a_dict: t.Dict[str, t.Optional[int]]) -> None:
a_list: List[str] = []
a_list.append("hello")
As a result, this plugin will emit:
hello.py:1:1: FA100 Missing from __future__ import annotations but imports: List, t.Dict, t.Optional
After adding the future annotations import, running pyupgrade allows the code to be automatically rewritten as:
from __future__ import annotations
def function(a_dict: dict[str, int | None]) -> None:
a_list: list[str] = []
a_list.append("hello")
Configuration
If the --force-future-annotations option is set, missing from __future__ import annotations will be reported regardless of a rewrite available according to PEP 563; in this case, code FA101 is used instead of FA100.
If the --check-future-annotations option is set, missing from __future__ import annotations will be reported because the following code will error on Python versions older than 3.10 (this check does not output anything for versions 3.10+):
def function(a_dict: dict[str, int | None]) -> None:
a_list: list[str] = []
a_list.append("hello")
hello.py:1:1: FA102 Missing from __future__ import annotations but uses simplified type annotations: dict, list, union
Metadata
Release files for flake8-future-annotations 1.1.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 | Actions |
|---|---|---|---|---|
| flake8-future-annotations-1.1.0.tar.gz | 6.8 kB | Without provenance | Details for flake8-future-annotations-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flake8_future_annotations-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for flake8_future_annotations-1.1.0-py3-none-any.whl |
Total release size: 17.2 kB
Release files / flake8-future-annotations-1.1.0.tar.gz
| Download URL | flake8-future-annotations-1.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df416bd2b9e1eda7ea639a5fd2a083dabb942ffe49d197f836df380d0dcf6608
|
|
BLAKE2b-256 checksum How to use checksums |
ceebeee3a350b4c1cae50f9040e78b80b39a3a0d7a5165c5837b68bff00513b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|
Release files / flake8_future_annotations-1.1.0-py3-none-any.whl
| Download URL | flake8_future_annotations-1.1.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
555f16f51ae24ab4d0683b1ce8d0f59d36259c3a7e776bd5642f58c78ce7d3ab
|
|
BLAKE2b-256 checksum How to use checksums |
45e4e3e6f788d9d5b5ff9a5fe2ceb6aaff9dea248aaa24c0217866c65fa5d0bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|
Security for flake8-future-annotations 1.1.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.