Skip to main content

A flake plugin that checks for typing.TYPE_CHECKING-able imports

Project description

A plugin for flake8 that checks your code for imports that are only used in annotations. These imports can then be moved under an if typing.TYPE_CHECKING: block to prevent them being imported at runtime. This can minimise the number of runtime dependencies that your modules have and perhaps also reduce the likelyhood of a circular import.

For example:

import dataclasses
import datetime

@dataclasses.dataclass
class Person:
    name: str
    birthday: datetime.date

The above code will emit a lint (code: TCI100) telling you that it can be converted to this:

import dataclasses
import typing

if typing.TYPE_CHECKING:
    import datetime

@dataclasses.dataclass
class Person:
    name: str
    birthday: datetime.date

You can install the latest version from pypi using pip like so:

pip install flake8-typechecking_import

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_typechecking_import-0.5.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

flake8_typechecking_import-0.5-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file flake8_typechecking_import-0.5.tar.gz.

File metadata

File hashes

Hashes for flake8_typechecking_import-0.5.tar.gz
Algorithm Hash digest
SHA256 f3f4e0804615b80563adce9768c81448adcc9c77cd20b2b779d6f28d23f42060
MD5 d2d0c198212bf600760c597a514dce38
BLAKE2b-256 945cc7c39d55547e0b152912ad0c5acb48996fc79399d37772ea1d4c09aa0df1

See more details on using hashes here.

File details

Details for the file flake8_typechecking_import-0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_typechecking_import-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1194c64a9ebd1671ec2dcea6df07d7de12fff0b7371da76c885479cf2feaeb75
MD5 8fe36226356c55d2b78b5594f47895a7
BLAKE2b-256 58fb78164152d0090476cc46296e4d6d7cf45d768b8146e3dce44518a86701c4

See more details on using hashes here.

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