Metadata-Version: 2.1
Name: flake8-new-union-types
Version: 0.4.1
Summary: Flake8 plugin to enforce the new Union and Optional annotation syntax defined in PEP 604
Home-page: https://github.com/xome4ok/flake8-new-union-types
License: MIT
Keywords: flake8,flake8-plugin,linting,linter,code quality,pep604,pep 604,syntax
Author: Dmitriy Pryanichnikov
Author-email: dmitrii.prianichnikov@incountry.com
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Framework :: Flake8
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Dist: attrs (>=21.4.0)
Requires-Dist: flake8 (>=3.0.0)
Project-URL: Repository, https://github.com/xome4ok/flake8-new-union-types
Description-Content-Type: text/markdown

# flake8-new-union-types
[![Build Status](https://github.com/xome4ok/flake8-new-union-types/actions/workflows/check.yml/badge.svg?branch=main)](https://github.com/xome4ok/flake8-new-union-types/actions/workflows/check.yml)
[![PyPI](https://img.shields.io/pypi/v/flake8-new-union-types)](https://pypi.org/project/flake8-new-union-types/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flake8-new-union-types)](https://pypi.org/project/flake8-new-union-types/)
[![PyPI - License](https://img.shields.io/pypi/l/flake8-new-union-types)](https://pypi.org/project/flake8-new-union-types/)

Flake8 plugin to enforce the new `Union` and `Optional` annotation syntax defined in [PEP 604](https://peps.python.org/pep-0604/).

```python
Union[X, Y] = X | Y

Optional[X] = X | None
```

Note that it's impossible to use forward references in the new syntax, like this:

```python
"X" | int
```

such a case [can be expressed](https://bugs.python.org/issue45857) as a string containing both union terms:

```python
"X | int"
```

## Installation

```
pip install flake8-new-union-types
```

or if you use [poetry](https://python-poetry.org/):

```
poetry add --dev flake8-new-union-types
```

## Usage

## Error list

* NU001 Use `Foo | Bar` syntax instead of Union (PEP 604)
* NU002 Use `Foo | None` syntax instead of Optional (PEP 604)
* NU003 Present the whole expression as a string to annotate forward refs, e.g. `"int | Foo"` (PEP 604)

## Configuration

There is no way to configure the plugin at the moment.

