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
Hashes for flake8_noreturn-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ef610c02742084da9e7772fe28557ca6ed10ecea0760519c2cd49b4ef6ad037 |
|
MD5 | fb54e144e42c246f8fbac9149e60d003 |
|
BLAKE2b-256 | d65356743d4927f7285cf817497dc20236da7777d55a69b89676e26782bbe3fa |