Verifies python 3.7+ files use from __future__ import annotations
Project description
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.
For 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: F 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")
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flake8-future-annotations-0.0.4.tar.gz.
File metadata
- Download URL: flake8-future-annotations-0.0.4.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
609f7b72dafba55988acbc822a1aae6dde8ec2036d86751a627175dac3e58b46
|
|
| MD5 |
da4d12af2bf5e68744ad1227010727e4
|
|
| BLAKE2b-256 |
01dea6e961ac829942f18294ad44b2dab457b5a05c4917d7d6ce69b6dc0a3556
|
File details
Details for the file flake8_future_annotations-0.0.4-py3-none-any.whl.
File metadata
- Download URL: flake8_future_annotations-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43add640b11a47eb8cfd5380727d894c5f821b4b3de7e14200b27810b61ac329
|
|
| MD5 |
eae9e30c0b9abc32cddca44b4203c7e4
|
|
| BLAKE2b-256 |
8748026e401135f511b61b9601e4111f7472a4f187974a92ab5830ae74e218cb
|