From 3e27d87ad2323b1f863b2fb4e52e9ac2b9ff31cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Thu, 18 Nov 2021 09:27:14 +0100 Subject: [PATCH] Change ``NoReturn`` to be encapsulated in strings (#1252) * Change ``NoReturn`` to be encapsulated in strings Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- ChangeLog | 3 +++ astroid/nodes/node_ng.py | 11 ++++++----- astroid/nodes/scoped_nodes.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29ba4c395d..db5f5ee9a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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? diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 0d19dcaade..e690743477 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -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 @@ -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 diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index df153b8875..444e8a6511 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -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.