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
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_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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e5612ff1e60b33e3522e6d118cab2e15fa5ebf42150c17e3d93e1a3dc47b4e5
|
|
| MD5 |
24dc9a1d4342048b70396532ae195542
|
|
| BLAKE2b-256 |
7de2f89e5002bc9e52fda205accb95ad1c2f7d304884375931cc6bd70d968561
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1446661c1bcd17603cd741a1d9ec71fcfbce29b470843a5150df82512e0b6c7
|
|
| MD5 |
d89c9e753ed12aa6d637678830f18efc
|
|
| BLAKE2b-256 |
6ff4580b9376613bed0881408d579733327accf956f89d7f8efc998bcd9c9d94
|