Skip to main content

flake8-noreturn

pre-commit.ci status Maintainability

Flake8 plugin to check for using -> None: type hint for return type. Helps to replace them with -> NoRetun type hint from typing.

Why to use NoReturn type hint?

Using NoReturn type hint:

  • is more explicit and helps to avoid confusion with None value,
  • helps to avoid bugs when using None as a default value for function arguments.
  • helps mypy to detect unreachable code

Installation

Use pip to install the package:

$ pip3 install flake8-noreturn

Usage

$ flake8 .

to select only flake8-noreturn errors:

$ flake8 --select NR .

Rules

Currently, the plugin checks implements only one rule:

NR001 Using -> None. Indicates usage of -> None: type hint for return type.

Examples:

def foo() -> None:
    pass

will raise NR001.

from typing import NoReturn

def foo() -> NoReturn:
    pass

will not raise NR001.

def foo() -> tuple[int, None]:
    return 2, None

will not raise NR001.

There is a flake8-no-types which was a heavy inspiration for this project.

Credits

Thank you adamchainz for the inspiring article and the flake8-no-types which helped me to create this plugin.

License

MIT © Krystian Safjan.

Metadata

Release files for flake8-noreturn 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-noreturn 1.0.1
File Size Uploaded Provenance
flake8_noreturn-1.0.1.tar.gz 3.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8-noreturn 1.0.1
File Interpreter ABI Platform
flake8_noreturn-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / flake8_noreturn-1.0.1.tar.gz

Download URL flake8_noreturn-1.0.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
83f707ba43293c6cb07990e9d4c23dd3649406e2bb13ffce014591793e273b28
BLAKE2b-256 checksum
How to use checksums
1dcfbe7b1068344c06d393c06175fe9ccc9e100ba9be82fc713075d4f7782a69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0

Release files / flake8_noreturn-1.0.1-py3-none-any.whl

Download URL flake8_noreturn-1.0.1-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6726ec0088eba38a10784fd75744c0fedbdf1a13de900a4bcae7fe73f0316847
BLAKE2b-256 checksum
How to use checksums
76ff65f6cfbd45cf12d7bc809e84ffb37fed7662edd40ecd5d70b8785fc59706
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0

Security for flake8-noreturn 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page