Skip to main content

A flake8 plugin to check typing import style

Project description

flake8-typing-as-t

PyPI - Version PyPI - Python Version


Table of Contents

Overview

This is a flake8 plugin which ensures that imports from the typing library must be written using import typing as t.

Installation

pip install flake8-typing-as-t

Checks

  • TYT01: Bare import typing usage
  • TYT02: import typing as X where X is not literal t
  • TYT03: from typing import X usage

Handling typing-extensions

A common pattern for compatibility is to do a sys.version_info-guarded dispatch over typing_extensions. e.g.

if sys.version_info < (3, 8):
    from typing_extensions import Literal
else:
    from typing import Literal

flake8-typing-as-t allows for this usage by checking if the import is inside of a test on sys.version_info against a tuple.

License

flake8-typing-as-t is distributed under the terms of the MIT license.

Changelog

1.0.0

  • Initial production release

0.0.3

  • Internal refactoring for improved performance

0.0.2

  • Add support for sys.version_info dispatch

0.0.1

  • Initial release

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_typing_as_t-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

flake8_typing_as_t-1.0.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file flake8_typing_as_t-1.0.0.tar.gz.

File metadata

  • Download URL: flake8_typing_as_t-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for flake8_typing_as_t-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5ac6951e7c2550f267e8a7438de6086ba1bcc5a8ce369299b4efc68a8b8740db
MD5 b1d3855eb2eb67f0ad83231f34432079
BLAKE2b-256 856c2a9f6fac6912a36c96582ffafdbc09d99d553511566cd348b03269eca90c

See more details on using hashes here.

Provenance

File details

Details for the file flake8_typing_as_t-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_typing_as_t-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d6953d3ea5a8eef64478de90c6ac5371611e61c51787728a8705f5ddf464b9b
MD5 2891d0f129a09928f8ff5e795352a8a2
BLAKE2b-256 319070a9c8c88f97353f10f8a262d5603cb6fd3555afdeb294331e5086479f4c

See more details on using hashes here.

Provenance

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