Skip to content

Commit

Permalink
Change NoReturn to be encapsulated in strings (#1252)
Browse files Browse the repository at this point in the history
* Change ``NoReturn`` to be encapsulated in strings

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
  • Loading branch information
DanielNoord and cdce8p authored Nov 18, 2021
1 parent fdc663e commit 3e27d87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ What's New in astroid 2.8.6?
============================
Release date: TBA

* Fix bug with Python 3.7.0 / 3.7.1 and ``typing.NoReturn``.

Closes #1239


What's New in astroid 2.8.5?
Expand Down
11 changes: 6 additions & 5 deletions astroid/nodes/node_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
if TYPE_CHECKING:
from astroid import nodes

if sys.version_info >= (3, 6, 2):
from typing import NoReturn
else:
from typing_extensions import NoReturn
if sys.version_info >= (3, 6, 2):
# To be fixed with https://github.com/PyCQA/pylint/pull/5316
from typing import NoReturn # pylint: disable=unused-import
else:
from typing_extensions import NoReturn

if sys.version_info >= (3, 8):
from typing import Literal
Expand Down Expand Up @@ -276,7 +277,7 @@ def statement(self, *, future: Literal[True]) -> "nodes.Statement":

def statement(
self, *, future: Literal[None, True] = None
) -> Union["nodes.Statement", "nodes.Module", NoReturn]:
) -> Union["nodes.Statement", "nodes.Module", "NoReturn"]:
"""The first parent node, including self, marked as statement node.
TODO: Deprecate the future parameter and only raise StatementMissing and return
Expand Down
2 changes: 1 addition & 1 deletion astroid/nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def statement(self, *, future: Literal[True]) -> NoReturn:

def statement(
self, *, future: Literal[None, True] = None
) -> Union[NoReturn, "Module"]:
) -> Union["NoReturn", "Module"]:
"""The first parent node, including self, marked as statement node.
When called on a :class:`Module` with the future parameter this raises an error.
Expand Down

0 comments on commit 3e27d87

Please sign in to comment.