Skip to main content

Flake8 plugin to enforce the new Union and Optional annotation syntax defined in PEP 604

Project description

flake8-new-union-types

Build Status PyPI PyPI - Python Version PyPI - License

Flake8 plugin to enforce the new Union and Optional annotation syntax defined in PEP 604.

Union[X, Y] = X | Y

Optional[X] = X | None

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

"X" | int

such a case can be expressed as a string containing both union terms:

"X | int"

Installation

pip install flake8-new-union-types

or if you use poetry:

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.

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-new-union-types-0.4.0.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

flake8_new_union_types-0.4.0-py3-none-any.whl (4.6 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