Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive inconsistent-return-statements with NoReturn function #4315

Closed
jamesbraza opened this issue Apr 7, 2021 · 2 comments
Closed
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@jamesbraza
Copy link

Steps to reproduce

Given a file a.py:

# pylint: disable=missing-docstring

from typing import NoReturn

def no_return(exc: Exception) -> NoReturn:
    """This function doesn't return, as shown by type hint of NoReturn."""
    raise Exception("Blows up") from exc

def return_int() -> int:
    """Function that doesn't return upon ValueError."""
    try:
        return 5
    except ValueError as exc:
        no_return(exc)

Current behavior

Result of pylint a.py:

a.py:9:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)

Expected behavior

Since there is not a return during the except case, this pylint error is a false positive.

pylint --version output

Result of pylint --version output:

pylint 2.7.4
astroid 2.5.2
Python 3.8.5 (default, Oct 26 2020, 18:36:15)
[Clang 12.0.0 (clang-1200.0.32.27)]
@cdce8p
Copy link
Member

cdce8p commented Apr 8, 2021

This functionality was added yesterday, see #4304 😃
Just for reference, duplicate of #4122

@cdce8p cdce8p closed this as completed Apr 8, 2021
@cdce8p cdce8p added the Duplicate 🐫 Duplicate of an already existing issue label Apr 8, 2021
@jamesbraza
Copy link
Author

Wow this is a blatant duplicate with quite coincidental timing. Glad it's resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

2 participants