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.

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-0.0.2.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

flake8_typing_as_t-0.0.2-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

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