Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xome4ok/flake8-new-union-types
Flake8 plugin to enforce the new Union and Optional annotation syntax defined in PEP 604
https://github.com/xome4ok/flake8-new-union-types
Last synced: 3 months ago
JSON representation
Flake8 plugin to enforce the new Union and Optional annotation syntax defined in PEP 604
- Host: GitHub
- URL: https://github.com/xome4ok/flake8-new-union-types
- Owner: xome4ok
- License: mit
- Created: 2022-05-13T11:58:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-07T14:02:10.000Z (9 months ago)
- Last Synced: 2024-10-14T11:19:44.988Z (4 months ago)
- Language: Python
- Homepage:
- Size: 43 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flake8-extensions - flake8-new-union-types - Plugin to enforce new Union/Optional syntax `Foo | Bar | None` defined in [PEP 604][pep604]. (Type annotations)
README
# ⛔️ This package is deprecated!
# Consider using https://github.com/astral-sh/ruff as it supports this check and a lot more
# 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 | YOptional[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.