summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-11-18 09:27:14 +0100
committerGitHub <noreply@github.com>2021-11-18 09:27:14 +0100
commit3e27d87ad2323b1f863b2fb4e52e9ac2b9ff31cf (patch)
treeec9774a1c698e340cb281fb7d0c086371fd0251c
parentfdc663eef855b06c78fbd15680bc050a12883d4a (diff)
downloadastroid-git-3e27d87ad2323b1f863b2fb4e52e9ac2b9ff31cf.tar.gz
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>
-rw-r--r--ChangeLog3
-rw-r--r--astroid/nodes/node_ng.py11
-rw-r--r--astroid/nodes/scoped_nodes.py2
3 files changed, 10 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 29ba4c39..db5f5ee9 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 0d19dcaa..e6907434 100644
--- a/astroid/nodes/node_ng.py
+++ b/astroid/nodes/node_ng.py
@@ -32,10 +32,11 @@ from astroid.nodes.const import OP_PRECEDENCE
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 @@ class NodeNG:
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 df153b88..444e8a65 100644
--- a/astroid/nodes/scoped_nodes.py
+++ b/astroid/nodes/scoped_nodes.py
@@ -662,7 +662,7 @@ class Module(LocalsDictNodeNG):
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.