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.3.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flake8_typechecking_import-0.3-py2.py3-none-any.whl (15.8 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: flake8_typechecking_import-0.3.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for flake8_typechecking_import-0.3.tar.gz
Algorithm Hash digest
SHA256 8e5612ff1e60b33e3522e6d118cab2e15fa5ebf42150c17e3d93e1a3dc47b4e5
MD5 24dc9a1d4342048b70396532ae195542
BLAKE2b-256 7de2f89e5002bc9e52fda205accb95ad1c2f7d304884375931cc6bd70d968561

See more details on using hashes here.

File details

Details for the file flake8_typechecking_import-0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: flake8_typechecking_import-0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for flake8_typechecking_import-0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e1446661c1bcd17603cd741a1d9ec71fcfbce29b470843a5150df82512e0b6c7
MD5 d89c9e753ed12aa6d637678830f18efc
BLAKE2b-256 6ff4580b9376613bed0881408d579733327accf956f89d7f8efc998bcd9c9d94

See more details on using hashes here.

Supported by

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