Metadata-Version: 2.1
Name: flake-type-annotations-plugin
Version: 0.2.0
Summary: flake8 plugin for type annotations
Home-page: https://github.com/waszker/flake-type-annotations-plugin
Author: Piotr Waszkiewicz
Author-email: waszka23@gmail.com
License: MIT
Project-URL: Bug Reports, https://github.com/waszker/flake-type-annotations-plugin/issues
Project-URL: Source, https://github.com/waszker/flake-type-annotations-plugin
Keywords: python,flake8,type annotations
Classifier: Framework :: Flake8
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.7, <4
Description-Content-Type: text/markdown
License-File: LICENSE.rst

## Flake type annotations plugin

[![Python Version](https://img.shields.io/pypi/pyversions/flake-type-annotations-plugin.svg)](https://pypi.org/project/flake-type-annotations-plugin/)
[![PyPI version](https://badge.fury.io/py/flake-type-annotations-plugin.svg)](https://pypi.org/project/flake-type-annotations-plugin/)
[![PyPI - License](https://img.shields.io/pypi/l/flake8-annotations?color=magenta)](https://github.com/sco1/flake8-annotations/blob/master/LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black)

The `flake8` plugin checking for correct usage of the Python type annotations.

Use with [flake8-annotations](https://pypi.org/project/flake8-annotations/) for even better results!

## Installation

Plugin requires `flake8 >3.0.0`

```bash
pip install flake-type-annotations-plugin
```

## Rules

### `TAN001`

This rule disallows usage of `Union` and `Optional` type annotations and expects user 
to use the new `|` operator syntax.

Example:

```python
# WRONG
from typing import Optional, Union

def func(arg: Optional[int]) -> Union[int, str]:  # violates TAN001
    return arg if arg is not None else "N/A"

# CORRECT
def func(arg: int | None) -> int | str:  # OK
    return arg if arg is not None else "N/A"
```

For Python versions `<3.10` a top-level module import 
`from __future__ import annotations` must be included in order to use this 
syntax.

More can be read in [PEP604](https://peps.python.org/pep-0604/).

### `TAN002`

This rule disallows usage of type annotations where built-in types can be used.

Example:

```python
# WRONG
from typing import List, Tuple

def func(arg: Tuple[int]) -> List[int]:  # violates TAN002
    return list(arg)

# CORRECT
def func(arg: tuple[int]) -> list[int]:  # OK
    return list(arg)
```

For Python versions `<3.9` a top-level module import
`from __future__ import annotations` must be included in order to use this
syntax.

More can be read in [PEP585](https://peps.python.org/pep-0585/).
