A flake8 plugin to detect return None (-> None) type hints.
Project description
flake8-noreturn
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.
Related Projects
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8_noreturn-1.0.1.tar.gz
.
File metadata
- Download URL: flake8_noreturn-1.0.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83f707ba43293c6cb07990e9d4c23dd3649406e2bb13ffce014591793e273b28 |
|
MD5 | 043f8a6df495aee3008900eb91f7cd62 |
|
BLAKE2b-256 | 1dcfbe7b1068344c06d393c06175fe9ccc9e100ba9be82fc713075d4f7782a69 |
File details
Details for the file flake8_noreturn-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: flake8_noreturn-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6726ec0088eba38a10784fd75744c0fedbdf1a13de900a4bcae7fe73f0316847 |
|
MD5 | 57236443e3a5fdda226cd6360c88d22a |
|
BLAKE2b-256 | 76ff65f6cfbd45cf12d7bc809e84ffb37fed7662edd40ecd5d70b8785fc59706 |