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
Close
Hashes for flake8-future-annotations-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 609f7b72dafba55988acbc822a1aae6dde8ec2036d86751a627175dac3e58b46 |
|
MD5 | da4d12af2bf5e68744ad1227010727e4 |
|
BLAKE2b-256 | 01dea6e961ac829942f18294ad44b2dab457b5a05c4917d7d6ce69b6dc0a3556 |
Close
Hashes for flake8_future_annotations-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43add640b11a47eb8cfd5380727d894c5f821b4b3de7e14200b27810b61ac329 |
|
MD5 | eae9e30c0b9abc32cddca44b4203c7e4 |
|
BLAKE2b-256 | 8748026e401135f511b61b9601e4111f7472a4f187974a92ab5830ae74e218cb |