Skip to main content

flake8 plugin to improve your type hints

Project description

flake8-kotoha

KoToHa: Kaizen Type Hint

Install

pipx

$ pipx install flake8
$ pipx inject flake8 flake8-kotoha
$ flake8 -h
...
Installed plugins: flake8-kotoha: 0.1.0, ...

venv + pip

$ python -m venv .venv --upgrade-deps
$ .venv/bin/python -m pip install flake8-kotoha
$ .venv/bin/flake8 -h
...
Installed plugins: flake8-kotoha: 0.1.0, ...

Usage

def plus_one(numbers: list[int]) -> list[int]:
    return [n + 1 for n in numbers]
$ flake8 example.py
example.py:1:14: KTH101 Type hint with abstract type `collections.abc.Iterable` or `collections.abc.Sequence`, instead of concrete type `list`

Error codes

Type hints in function parameters

Use abstract types instead of concrete ones

error code description
KTH101 Use Iterable or Sequence instead of list
KTH102 Use Iterable or Sequence instead of tuple
KTH103 Use Iterable instead of set
KTH104 Use Iterable instead of dict

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_kotoha-0.1.0.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

flake8_kotoha-0.1.0-py3-none-any.whl (4.7 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