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

Add broken NoReturn check #5304

Merged
merged 16 commits into from Mar 10, 2022
Merged

Add broken NoReturn check #5304

merged 16 commits into from Mar 10, 2022

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Nov 14, 2021

Type of Changes

Type
✨ New feature

Description

Response to: pylint-dev/astroid#1239

Add a new check to detect broken uses for typing.NoReturn in 3.7.0 / 3.7.1.
I'm open to changing the checker name if something better than broken-noreturn is found :)

@Pierre-Sassoulas
Copy link
Member

Shouldn't this be in flake8-typing-imports instead ? We were going to add it to our own pre-commit configuration in #5070 (and astroid too)

@cdce8p
Copy link
Member Author

cdce8p commented Nov 14, 2021

Shouldn't this be in flake8-typing-imports instead ? We were going to add it to our own pre-commit configuration in #5070 (and astroid too)

Not sure Anthony will add it ;)
Technically, NoReturn can be imported and even used, it's just broken in these special cases. So I'm not sure what flake8-typing-import should emit. Importing it from typing_extensions doesn't fix this issue either.

@Pierre-Sassoulas
Copy link
Member

Technically, NoReturn can be imported and even used, it's just broken in these special cases.

Ok, that makes sense. Trying not to add anything in 2.12 so we can release though :)

Not sure Anthony will add it ;)

Yeah, it's often a struggle.

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.0 milestone Nov 14, 2021
@coveralls
Copy link

coveralls commented Nov 14, 2021

Pull Request Test Coverage Report for Build 1963926454

  • 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 94.006%

Totals Coverage Status
Change from base Build 1963138182: 0.006%
Covered Lines: 14961
Relevant Lines: 15915

💛 - Coveralls

@Pierre-Sassoulas Pierre-Sassoulas added Checkers Related to a checker Enhancement ✨ Improvement to a component labels Nov 14, 2021
@Pierre-Sassoulas
Copy link
Member

I'm open to changing the checker name if something better than broken-noreturn is found :)

invalid-no-return-as-typing-argument ? It's a little lengthy.

@cdce8p
Copy link
Member Author

cdce8p commented Nov 14, 2021

I'm open to changing the checker name if something better than broken-noreturn is found :)

invalid-no-return-as-typing-argument ? It's a little lengthy.

Doesn't really fit IMO. NoReturn isn't invalid itself. It's just the specific usage that breaks.

@Pierre-Sassoulas
Copy link
Member

It's just the specific usage that breaks.

I thought this usage where it's not valid was when it's used as a typing argument ?

@cdce8p
Copy link
Member Author

cdce8p commented Nov 14, 2021

You can still use it like this

def func() -> NoReturn:
    ...

Alias = Union[None, 'NoReturn']  # note the use of ' '

at least if you don't need to call typing.get_type_annotations.

@cdce8p
Copy link
Member Author

cdce8p commented Nov 14, 2021

It's just the specific usage that breaks.

I thought this usage where it's not valid was when it's used as a typing argument ?

The uses are valid. It just breaks because of https://bugs.python.org/issue34921

@DanielNoord
Copy link
Collaborator

@cdce8p Is this ready for review (barring the merge conflicts)?

@cdce8p
Copy link
Member Author

cdce8p commented Dec 4, 2021

@cdce8p Is this ready for review (barring the merge conflicts)?

Yes. I just resolved the merged conflicts.

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One little question. Rest looks good!

tests/functional/ext/typing/typing_broken_noreturn.py Outdated Show resolved Hide resolved
@DanielNoord DanielNoord added the Waiting on author Indicate that maintainers are waiting for a message of the author label Dec 14, 2021
@Pierre-Sassoulas Pierre-Sassoulas removed the Waiting on author Indicate that maintainers are waiting for a message of the author label Dec 17, 2021
@cdce8p cdce8p mentioned this pull request Dec 30, 2021
15 tasks
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@DanielNoord DanielNoord added the Waiting on author Indicate that maintainers are waiting for a message of the author label Jan 10, 2022
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.13.0, 2.14.0 Feb 2, 2022
pylint/extensions/typing.py Outdated Show resolved Hide resolved
pylint/extensions/typing.py Outdated Show resolved Hide resolved
@cdce8p cdce8p modified the milestones: 2.14.0, 2.13.0 Mar 10, 2022
@cdce8p cdce8p removed the Waiting on author Indicate that maintainers are waiting for a message of the author label Mar 10, 2022
@cdce8p
Copy link
Member Author

cdce8p commented Mar 10, 2022

Need to do one more change. So far I've ignored from __future__ import annotations here.

Update: cc7fb08

@cdce8p cdce8p merged commit 1faf365 into pylint-dev:main Mar 10, 2022
@cdce8p cdce8p deleted the feat_broken-noreturn branch March 10, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Checkers Related to a checker Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants