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

Use NoReturn to avoid "inconsistent-return-statements" false positives #4122

Closed
tyralla opened this issue Feb 22, 2021 · 0 comments · Fixed by #4304
Closed

Use NoReturn to avoid "inconsistent-return-statements" false positives #4122

tyralla opened this issue Feb 22, 2021 · 0 comments · Fixed by #4304

Comments

@tyralla
Copy link

tyralla commented Feb 22, 2021

This is a duplicate of #3188 but comes with a suggestion.

Maybe Pylint could use the "NoReturn" type hint to stop raising unnecessary "inconsistent-return-statements" warnings?

It would be convenient if the following would pass:

from typing import NoReturn


def error(value: float) -> NoReturn:
    raise TypeError(f"Cannot do math with type {type(value).__name__}")


def do_math(value: float) -> float:
    try:
        return value + 1.0
    except TypeError:
        error(value)
tyralla added a commit to hydpy-dev/hydpy that referenced this issue Feb 24, 2021
For pylint 2.7, this warning appears multiple times and is related to using the `augment_excmessage` function of module `objecttools`. Pylint does not understand that this function never returns.

I opened issue pylint-dev/pylint#4122. Once accepted and implemented, we can reverse this commit. If the proposal is rejected, we have to decide whether we want to keep the global setting or write the corresponding comment to each individual corresponding function call.

It seems like Pylint does not understand some of our descriptors (e.g. `_PubProperty`) well enough and thus raises false-positive `no-member´ warnings.

This seems to be a know issue.  If someone fixes pylint-dev/pylint#3684, we can revert this commit.

Adding local disable-statements would be much effort. It seems better to wait and further improve our type hints in the meantime, so that Mypy can step in to catch potential `no-member` bugs.
@cdce8p cdce8p modified the milestone: 2.7.5 Apr 7, 2021
pkolbus added a commit to pkolbus/pylint that referenced this issue May 6, 2021
typing.NoReturn was introduced in Python 3.6.2. Move the tests for
issue pylint-dev#4122 to a separate file and skip when Python is too old.
pkolbus added a commit to pkolbus/pylint that referenced this issue May 9, 2021
typing.NoReturn was introduced in Python 3.6.2. Move the tests for
issue pylint-dev#4122 to a separate file and skip when Python is too old.
pkolbus added a commit to pkolbus/pylint that referenced this issue May 12, 2021
typing.NoReturn was introduced in Python 3.6.2. Move the tests for
issue pylint-dev#4122 to a separate file and skip when Python is too old.

Co-authored-by: Marc Mueller <[email protected]>
cdce8p pushed a commit that referenced this issue May 12, 2021
* tox: Enable testing python 3.6.0

The requirements_test.txt includes black, pre-commit, and pyupgrade
which are not compatible with Python 3.6.0. Add python_full_version
markers so that `tox -e py36` works with 3.6.0.

* Fix typing.Counter import for Python 3.6.0

typing.Counter was added in Python 3.6.1. In the strings checker,
guard the import with TYPE_CHECKING and use a type annotation comment
to fix usage with Python 3.6.0.

* Skip typing.NoReturn tests on Python < 3.6.2

typing.NoReturn was introduced in Python 3.6.2. Move the tests for
issue #4122 to a separate file and skip when Python is too old.

* Update ChangeLog and whatsnew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants