Skip to main content

Verifies python 3.7+ files use from __future__ import annotations

Project description

flake8-future-annotations

Python 3.7+ PyPI version GitHub license Downloads

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

flake8-future-annotations-0.0.4.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

flake8_future_annotations-0.0.4-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page