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
File details
Details for the file flake8_typechecking_import-0.5.tar.gz
.
File metadata
- Download URL: flake8_typechecking_import-0.5.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3f4e0804615b80563adce9768c81448adcc9c77cd20b2b779d6f28d23f42060 |
|
MD5 | d2d0c198212bf600760c597a514dce38 |
|
BLAKE2b-256 | 945cc7c39d55547e0b152912ad0c5acb48996fc79399d37772ea1d4c09aa0df1 |
File details
Details for the file flake8_typechecking_import-0.5-py3-none-any.whl
.
File metadata
- Download URL: flake8_typechecking_import-0.5-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1194c64a9ebd1671ec2dcea6df07d7de12fff0b7371da76c885479cf2feaeb75 |
|
MD5 | 8fe36226356c55d2b78b5594f47895a7 |
|
BLAKE2b-256 | 58fb78164152d0090476cc46296e4d6d7cf45d768b8146e3dce44518a86701c4 |