From d8347f05ddb3f8d3e4705207ffb6b0aa5a69d46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Fri, 22 Oct 2021 17:29:44 +0200 Subject: [PATCH 01/21] Add typing to ``NodeNG.statement`` --- astroid/nodes/node_ng.py | 10 +++++++--- astroid/nodes/scoped_nodes.py | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 147e692210..cb70209fc0 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -10,6 +10,7 @@ Type, TypeVar, Union, + cast, overload, ) @@ -25,7 +26,7 @@ from astroid.nodes.const import OP_PRECEDENCE if TYPE_CHECKING: - from astroid.nodes import LocalsDictNodeNG + from astroid import nodes # Types for 'NodeNG.nodes_of_class()' T_Nodes = TypeVar("T_Nodes", bound="NodeNG") @@ -248,14 +249,17 @@ def parent_of(self, node): return True return False - def statement(self): + def statement(self) -> Union["nodes.Statement", "nodes.Module"]: """The first parent node, including self, marked as statement node. :returns: The first parent statement. :rtype: NodeNG """ if self.is_statement: + self = cast("nodes.Statement", self) return self + if not self.parent: + raise ParentMissingError(target=self) return self.parent.statement() def frame(self): @@ -269,7 +273,7 @@ def frame(self): """ return self.parent.frame() - def scope(self) -> "LocalsDictNodeNG": + def scope(self) -> "nodes.LocalsDictNodeNG": """The first parent node defining a new scope. These can be Module, FunctionDef, ClassDef, Lambda, or GeneratorExp nodes. diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index e9ccd4a2e1..300f794bb8 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -648,11 +648,10 @@ def fully_defined(self): """ return self.file is not None and self.file.endswith(".py") - def statement(self): + def statement(self) -> "Module": """The first parent node, including self, marked as statement node. :returns: The first parent statement. - :rtype: NodeNG """ return self From f9fe68d92dcdd33304074f55d85b6633a801c530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Tue, 2 Nov 2021 09:34:35 +0100 Subject: [PATCH 02/21] Rewrite to use ``StatementMissing`` --- astroid/exceptions.py | 13 +++++++++++++ astroid/nodes/node_ng.py | 7 +++++-- astroid/nodes/scoped_nodes.py | 15 ++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index 81d973031b..b4d65c704c 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -272,6 +272,19 @@ def __init__(self, target: "nodes.NodeNG") -> None: super().__init__(message=f"Parent not found on {target!r}.") +class StatementMissing(ParentMissingError): + """Raised when a call to node.statement() does not return a node. This is because + a node in the chain does not have a parent attribute and therefore does not + return a node for statement(). + + Standard attributes: + target: The node for which the parent lookup failed. + """ + + def __init__(self, target: "nodes.NodeNG") -> None: + self.target = target + super().__init__(message=f"Statement not found for {target!r}.") + # Backwards-compatibility aliases OperationError = util.BadOperationMessage UnaryOperationError = util.BadUnaryOperationMessage diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index cb70209fc0..da937ca4bb 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -19,6 +19,7 @@ AstroidError, InferenceError, ParentMissingError, + StatementMissing, UseInferenceDefault, ) from astroid.manager import AstroidManager @@ -249,17 +250,19 @@ def parent_of(self, node): return True return False - def statement(self) -> Union["nodes.Statement", "nodes.Module"]: + def statement(self) -> "nodes.Statement": """The first parent node, including self, marked as statement node. :returns: The first parent statement. :rtype: NodeNG + + :raises StatementMissing: If no self has no parent attribute """ if self.is_statement: self = cast("nodes.Statement", self) return self if not self.parent: - raise ParentMissingError(target=self) + raise StatementMissing(target=self) return self.parent.statement() def frame(self): diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index 300f794bb8..5fda2434fb 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -44,6 +44,7 @@ import io import itertools import os +import sys import typing from typing import List, Optional, TypeVar @@ -65,6 +66,7 @@ InconsistentMroError, InferenceError, MroError, + StatementMissing, TooManyLevelsError, ) from astroid.interpreter.dunder_lookup import lookup @@ -72,6 +74,11 @@ from astroid.manager import AstroidManager from astroid.nodes import Arguments, Const, node_classes +if sys.version_info >= (3, 6, 2): + from typing import NoReturn +else: + from typing_extensions import NoReturn + ITER_METHODS = ("__iter__", "__getitem__") EXCEPTION_BASE_CLASSES = frozenset({"Exception", "BaseException"}) objects = util.lazy_import("objects") @@ -648,12 +655,14 @@ def fully_defined(self): """ return self.file is not None and self.file.endswith(".py") - def statement(self) -> "Module": + def statement(self) -> NoReturn: """The first parent node, including self, marked as statement node. + + When called on a :class:`Module` this raises an error. - :returns: The first parent statement. + :raises StatementMissing: If no self has no parent attribute """ - return self + raise StatementMissing(target=self) def previous_sibling(self): """The previous sibling statement. From b6373e3c44642e272367669ae4e6f6d58e22592f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Nov 2021 08:35:21 +0000 Subject: [PATCH 03/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- astroid/exceptions.py | 1 + astroid/nodes/scoped_nodes.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index b4d65c704c..05488b4e4d 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -285,6 +285,7 @@ def __init__(self, target: "nodes.NodeNG") -> None: self.target = target super().__init__(message=f"Statement not found for {target!r}.") + # Backwards-compatibility aliases OperationError = util.BadOperationMessage UnaryOperationError = util.BadUnaryOperationMessage diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index e2054ae517..42544572ce 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -646,7 +646,7 @@ def fully_defined(self): def statement(self) -> NoReturn: """The first parent node, including self, marked as statement node. - + When called on a :class:`Module` this raises an error. :raises StatementMissing: If no self has no parent attribute From 19c5ed4acc2a7215ffbfa2849b8955d425def663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Wed, 3 Nov 2021 15:07:59 +0100 Subject: [PATCH 04/21] Add ``future`` parameter to ``NodeNG.statement()`` and add typing --- astroid/exceptions.py | 8 ++++---- astroid/nodes/node_ng.py | 37 +++++++++++++++++++++++++++++----- astroid/nodes/scoped_nodes.py | 37 +++++++++++++++++++++++++++------- tests/unittest_builder.py | 5 ++++- tests/unittest_nodes.py | 7 +++++++ tests/unittest_scoped_nodes.py | 4 ++++ 6 files changed, 81 insertions(+), 17 deletions(-) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index b4d65c704c..3382cea5bb 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -267,9 +267,9 @@ class ParentMissingError(AstroidError): target: The node for which the parent lookup failed. """ - def __init__(self, target: "nodes.NodeNG") -> None: + def __init__(self, target: "nodes.NodeNG", missing_element: str = "Parent") -> None: self.target = target - super().__init__(message=f"Parent not found on {target!r}.") + super().__init__(message=f"{missing_element} not found on {target!r}.") class StatementMissing(ParentMissingError): @@ -282,8 +282,8 @@ class StatementMissing(ParentMissingError): """ def __init__(self, target: "nodes.NodeNG") -> None: - self.target = target - super().__init__(message=f"Statement not found for {target!r}.") + super().__init__(target, "Statement") + # Backwards-compatibility aliases OperationError = util.BadOperationMessage diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 6e5053a49f..7b6981913f 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -1,4 +1,5 @@ import pprint +import sys import typing from functools import singledispatch as _singledispatch from typing import ( @@ -29,6 +30,12 @@ if TYPE_CHECKING: from astroid import nodes +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + + # Types for 'NodeNG.nodes_of_class()' T_Nodes = TypeVar("T_Nodes", bound="NodeNG") T_Nodes2 = TypeVar("T_Nodes2", bound="NodeNG") @@ -250,11 +257,29 @@ def parent_of(self, node): return True return False - def statement(self) -> "nodes.Statement": + @overload + def statement( + self, future: Literal[None] = ... + ) -> Union["nodes.Statement", "nodes.Module"]: + ... + + @overload + def statement( + self, future: Literal[False] + ) -> Union["nodes.Statement", "nodes.Module"]: + ... + + @overload + def statement(self, future: Literal[True]) -> "nodes.Statement": + ... + + def statement( + self, future: bool = False + ) -> Union["nodes.Statement", "nodes.Module"]: """The first parent node, including self, marked as statement node. - :returns: The first parent statement. - :rtype: NodeNG + TODO: Deprecate the future parameter and only raise StatementMissing and return + nodes.Statement :raises StatementMissing: If no self has no parent attribute """ @@ -262,8 +287,10 @@ def statement(self) -> "nodes.Statement": self = cast("nodes.Statement", self) return self if not self.parent: - raise StatementMissing(target=self) - return self.parent.statement() + if future: + raise StatementMissing(target=self) + raise AttributeError(f"{self} object has no attribute 'parent'") + return self.parent.statement(future) def frame( self, diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index e2054ae517..f88aa9c701 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -46,7 +46,7 @@ import os import sys import typing -from typing import List, Optional, TypeVar +from typing import List, Optional, TypeVar, Union, overload from astroid import bases from astroid import decorators as decorators_mod @@ -79,6 +79,13 @@ else: from typing_extensions import NoReturn + +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + + ITER_METHODS = ("__iter__", "__getitem__") EXCEPTION_BASE_CLASSES = frozenset({"Exception", "BaseException"}) objects = util.lazy_import("objects") @@ -644,14 +651,30 @@ def fully_defined(self): """ return self.file is not None and self.file.endswith(".py") - def statement(self) -> NoReturn: + @overload + def statement(self, future: Literal[None] = ...) -> "Module": + ... + + @overload + def statement(self, future: Literal[False]) -> "Module": + ... + + @overload + def statement(self, future: Literal[True]) -> NoReturn: + ... + + def statement(self, future: bool = False) -> Union[NoReturn, "Module"]: """The first parent node, including self, marked as statement node. - - When called on a :class:`Module` this raises an error. - :raises StatementMissing: If no self has no parent attribute + When called on a :class:`Module` with the future paramter this raises an error. + + TODO: Deprecate the future parameter and only raise StatementMissing + + :raises StatementMissing: If no self has no parent attribute and future is True """ - raise StatementMissing(target=self) + if future: + raise StatementMissing(target=self) + return self def previous_sibling(self): """The previous sibling statement. @@ -2558,7 +2581,7 @@ def getattr(self, name, context=None, class_context=True): # Look for AnnAssigns, which are not attributes in the purest sense. for value in values: if isinstance(value, node_classes.AssignName): - stmt = value.statement() + stmt = value.statement(True) if isinstance(stmt, node_classes.AnnAssign) and stmt.value is None: raise AttributeInferenceError( target=self, attribute=name, context=context diff --git a/tests/unittest_builder.py b/tests/unittest_builder.py index 300e4e92d0..e7bd7ade45 100644 --- a/tests/unittest_builder.py +++ b/tests/unittest_builder.py @@ -38,6 +38,7 @@ AstroidSyntaxError, AttributeInferenceError, InferenceError, + StatementMissing, ) from astroid.nodes.scoped_nodes import Module @@ -614,7 +615,9 @@ def test_module_base_props(self) -> None: self.assertEqual(module.package, 0) self.assertFalse(module.is_statement) self.assertEqual(module.statement(), module) - self.assertEqual(module.statement(), module) + self.assertEqual(module.statement(False), module) + with self.assertRaises(StatementMissing): + module.statement(True) def test_module_locals(self) -> None: """test the 'locals' dictionary of an astroid module""" diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py index 73b4cecbd3..2782c5046f 100644 --- a/tests/unittest_nodes.py +++ b/tests/unittest_nodes.py @@ -55,6 +55,7 @@ AstroidBuildingError, AstroidSyntaxError, AttributeInferenceError, + StatementMissing, ) from astroid.nodes.node_classes import ( AssignAttr, @@ -626,6 +627,12 @@ def _test(self, value: Any) -> None: self.assertIs(node.value, value) self.assertTrue(node._proxied.parent) self.assertEqual(node._proxied.root().name, value.__class__.__module__) + with self.assertRaises(AttributeError): + node.statement() + with self.assertRaises(AttributeError): + node.statement(False) + with self.assertRaises(StatementMissing): + node.statement(True) def test_none(self) -> None: self._test(None) diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py index 2045e1732c..118dea6d31 100644 --- a/tests/unittest_scoped_nodes.py +++ b/tests/unittest_scoped_nodes.py @@ -323,6 +323,8 @@ def test_default_value(self) -> None: def test_navigation(self) -> None: function = self.module["global_access"] self.assertEqual(function.statement(), function) + self.assertEqual(function.statement(False), function) + self.assertEqual(function.statement(True), function) l_sibling = function.previous_sibling() # check taking parent if child is not a stmt self.assertIsInstance(l_sibling, nodes.Assign) @@ -821,6 +823,8 @@ def test_instance_special_attributes(self) -> None: def test_navigation(self) -> None: klass = self.module["YO"] self.assertEqual(klass.statement(), klass) + self.assertEqual(klass.statement(False), klass) + self.assertEqual(klass.statement(True), klass) l_sibling = klass.previous_sibling() self.assertTrue(isinstance(l_sibling, nodes.FunctionDef), l_sibling) self.assertEqual(l_sibling.name, "global_access") From 005a9ffebba3f2e2b8033b15e321b3d375ef199c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:09:58 +0000 Subject: [PATCH 05/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- astroid/exceptions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index d3c06fb1bc..3382cea5bb 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -285,7 +285,6 @@ def __init__(self, target: "nodes.NodeNG") -> None: super().__init__(target, "Statement") - # Backwards-compatibility aliases OperationError = util.BadOperationMessage UnaryOperationError = util.BadUnaryOperationMessage From da1b98917fab3c6b6bbc07a7d817ca6053cbc865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Wed, 3 Nov 2021 15:11:12 +0100 Subject: [PATCH 06/21] Update astroid/exceptions.py --- astroid/exceptions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index 3382cea5bb..06f94799b4 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -265,6 +265,7 @@ class ParentMissingError(AstroidError): Standard attributes: target: The node for which the parent lookup failed. + missing_element: The type of attribute/method that is missing because of the missing parent """ def __init__(self, target: "nodes.NodeNG", missing_element: str = "Parent") -> None: From d95d5ac1dcb1c5cdf2466f709dcfd7527fb127d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Wed, 3 Nov 2021 15:52:39 +0100 Subject: [PATCH 07/21] Fix overload --- astroid/nodes/node_ng.py | 17 ++++++++--------- astroid/nodes/scoped_nodes.py | 8 ++------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 7b6981913f..04462b965f 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -30,6 +30,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, 8): from typing import Literal else: @@ -259,23 +264,17 @@ def parent_of(self, node): @overload def statement( - self, future: Literal[None] = ... - ) -> Union["nodes.Statement", "nodes.Module"]: - ... - - @overload - def statement( - self, future: Literal[False] + self, future: Literal[False] = ... ) -> Union["nodes.Statement", "nodes.Module"]: ... @overload - def statement(self, future: Literal[True]) -> "nodes.Statement": + def statement(self, future: Literal[True]) -> Union[NoReturn, "nodes.Statement"]: ... def statement( self, future: bool = False - ) -> Union["nodes.Statement", "nodes.Module"]: + ) -> 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 3a12786e5d..64b4a1c6b6 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -652,15 +652,11 @@ def fully_defined(self): return self.file is not None and self.file.endswith(".py") @overload - def statement(self, future: Literal[None] = ...) -> "Module": + def statement(self, future: Literal[False] = ...) -> "Module": ... @overload - def statement(self, future: Literal[False]) -> "Module": - ... - - @overload - def statement(self, future: Literal[True]) -> NoReturn: + def statement(self, future: Literal[True] = ...) -> NoReturn: ... def statement(self, future: bool = False) -> Union[NoReturn, "Module"]: From ef019e67d5f9113d601e7b9dcd55a04e4f14487d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Wed, 3 Nov 2021 16:45:48 +0100 Subject: [PATCH 08/21] Update astroid/nodes/node_ng.py Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- astroid/nodes/node_ng.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 04462b965f..f7c0f9199a 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -283,8 +283,7 @@ def statement( :raises StatementMissing: If no self has no parent attribute """ if self.is_statement: - self = cast("nodes.Statement", self) - return self + return cast("nodes.Statement", self) if not self.parent: if future: raise StatementMissing(target=self) From 1f6ec98e299a07a3d6b11633d8c6b497ee957cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Thu, 4 Nov 2021 15:11:48 +0100 Subject: [PATCH 09/21] WIP Code Review --- astroid/nodes/node_ng.py | 15 ++++++--------- astroid/nodes/scoped_nodes.py | 8 +++++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index f7c0f9199a..35a992670a 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -30,10 +30,6 @@ 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, 8): from typing import Literal @@ -264,23 +260,24 @@ def parent_of(self, node): @overload def statement( - self, future: Literal[False] = ... + self, future: Literal[None] = ... ) -> Union["nodes.Statement", "nodes.Module"]: ... @overload - def statement(self, future: Literal[True]) -> Union[NoReturn, "nodes.Statement"]: + def statement(self, future: Literal[True]) -> "nodes.Statement": ... def statement( - self, future: bool = False - ) -> Union["nodes.Statement", "nodes.Module", NoReturn]: + self, future: Optional[Literal[True]] = None + ) -> Union["nodes.Statement", "nodes.Module"]: """The first parent node, including self, marked as statement node. TODO: Deprecate the future parameter and only raise StatementMissing and return nodes.Statement - :raises StatementMissing: If no self has no parent attribute + :raises AttributeError: If self has no parent attribute + :raises StatementMissing: If self has no parent attribute and future is True """ if self.is_statement: return cast("nodes.Statement", self) diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index 64b4a1c6b6..19b39125e9 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -652,14 +652,16 @@ def fully_defined(self): return self.file is not None and self.file.endswith(".py") @overload - def statement(self, future: Literal[False] = ...) -> "Module": + def statement(self, future: Literal[None] = ...) -> "Module": ... @overload - def statement(self, future: Literal[True] = ...) -> NoReturn: + def statement(self, future: Literal[True]) -> NoReturn: ... - def statement(self, future: bool = False) -> Union[NoReturn, "Module"]: + def statement( + self, future: Union[Literal[True]] = None + ) -> 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. From df9b49cea85e3f5e09902a59fa2ab1a3a4e71ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Thu, 4 Nov 2021 15:29:27 +0100 Subject: [PATCH 10/21] Update astroid/nodes/scoped_nodes.py Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- astroid/nodes/scoped_nodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index 19b39125e9..c347715b02 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -660,7 +660,7 @@ def statement(self, future: Literal[True]) -> NoReturn: ... def statement( - self, future: Union[Literal[True]] = None + self, future: Optional[Literal[True]] = None ) -> Union[NoReturn, "Module"]: """The first parent node, including self, marked as statement node. From 6026560846c00ade3c6f2d2f89f71331300e10e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Thu, 4 Nov 2021 15:33:57 +0100 Subject: [PATCH 11/21] Add NoReturn --- astroid/nodes/node_ng.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 35a992670a..dc7e3db8d1 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -30,6 +30,10 @@ 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, 8): from typing import Literal @@ -270,7 +274,7 @@ def statement(self, future: Literal[True]) -> "nodes.Statement": def statement( self, future: Optional[Literal[True]] = None - ) -> Union["nodes.Statement", "nodes.Module"]: + ) -> 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 From d07374ceda60695b92466948e927e72a274661ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sat, 6 Nov 2021 18:08:58 +0200 Subject: [PATCH 12/21] Code review --- astroid/exceptions.py | 8 +++++--- astroid/nodes/node_ng.py | 7 +++++++ astroid/nodes/scoped_nodes.py | 7 +++++++ tests/unittest_builder.py | 1 - 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index 06f94799b4..d20a3706b4 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -268,9 +268,9 @@ class ParentMissingError(AstroidError): missing_element: The type of attribute/method that is missing because of the missing parent """ - def __init__(self, target: "nodes.NodeNG", missing_element: str = "Parent") -> None: + def __init__(self, target: "nodes.NodeNG") -> None: self.target = target - super().__init__(message=f"{missing_element} not found on {target!r}.") + super().__init__(message=f"Parent not found on {target!r}.") class StatementMissing(ParentMissingError): @@ -283,7 +283,9 @@ class StatementMissing(ParentMissingError): """ def __init__(self, target: "nodes.NodeNG") -> None: - super().__init__(target, "Statement") + super(ParentMissingError, self).__init__( + message=f"Statement not found on {target!r}" + ) # Backwards-compatibility aliases diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index dc7e3db8d1..b6ba7936a2 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -1,6 +1,7 @@ import pprint import sys import typing +import warnings from functools import singledispatch as _singledispatch from typing import ( TYPE_CHECKING, @@ -288,6 +289,12 @@ def statement( if not self.parent: if future: raise StatementMissing(target=self) + warnings.warn( + "In astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement " + "or raise a StatementMissing exception. This behaviour can already be triggered " + "by passing 'future=True' to a statement() call.", + DeprecationWarning, + ) raise AttributeError(f"{self} object has no attribute 'parent'") return self.parent.statement(future) diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index c347715b02..3841113073 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -46,6 +46,7 @@ import os import sys import typing +import warnings from typing import List, Optional, TypeVar, Union, overload from astroid import bases @@ -672,6 +673,12 @@ def statement( """ if future: raise StatementMissing(target=self) + warnings.warn( + "In astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement " + "or raise a StatementMissing exception. This behaviour can already be triggered " + "by passing 'future=True' to a statement() call.", + DeprecationWarning, + ) return self def previous_sibling(self): diff --git a/tests/unittest_builder.py b/tests/unittest_builder.py index e7bd7ade45..662700a9d5 100644 --- a/tests/unittest_builder.py +++ b/tests/unittest_builder.py @@ -615,7 +615,6 @@ def test_module_base_props(self) -> None: self.assertEqual(module.package, 0) self.assertFalse(module.is_statement) self.assertEqual(module.statement(), module) - self.assertEqual(module.statement(False), module) with self.assertRaises(StatementMissing): module.statement(True) From 2596ee679b0f1e107c484149828926f879621381 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 6 Nov 2021 16:09:46 +0000 Subject: [PATCH 13/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- astroid/nodes/scoped_nodes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index 3841113073..dddfefdcd6 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -674,11 +674,11 @@ def statement( if future: raise StatementMissing(target=self) warnings.warn( - "In astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement " - "or raise a StatementMissing exception. This behaviour can already be triggered " - "by passing 'future=True' to a statement() call.", - DeprecationWarning, - ) + "In astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement " + "or raise a StatementMissing exception. This behaviour can already be triggered " + "by passing 'future=True' to a statement() call.", + DeprecationWarning, + ) return self def previous_sibling(self): From e8d0ff2267e0f4edeaaa929b8c83b8c39a09bca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sat, 6 Nov 2021 17:10:40 +0100 Subject: [PATCH 14/21] Apply suggestions from code review Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- astroid/nodes/node_ng.py | 2 +- astroid/nodes/scoped_nodes.py | 4 +++- tests/unittest_nodes.py | 2 -- tests/unittest_scoped_nodes.py | 2 -- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index b6ba7936a2..224f68548f 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -274,7 +274,7 @@ def statement(self, future: Literal[True]) -> "nodes.Statement": ... def statement( - self, future: Optional[Literal[True]] = None + self, future: Literal[None, True] = None ) -> Union["nodes.Statement", "nodes.Module", NoReturn]: """The first parent node, including self, marked as statement node. diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index dddfefdcd6..cde648fc2a 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -656,12 +656,14 @@ def fully_defined(self): def statement(self, future: Literal[None] = ...) -> "Module": ... + # pylint: disable-next=signature-differs + # https://github.com/PyCQA/pylint/issues/5264 @overload def statement(self, future: Literal[True]) -> NoReturn: ... def statement( - self, future: Optional[Literal[True]] = None + self, future: Literal[None, True] = None ) -> Union[NoReturn, "Module"]: """The first parent node, including self, marked as statement node. diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py index 2782c5046f..5f7cae67bf 100644 --- a/tests/unittest_nodes.py +++ b/tests/unittest_nodes.py @@ -629,8 +629,6 @@ def _test(self, value: Any) -> None: self.assertEqual(node._proxied.root().name, value.__class__.__module__) with self.assertRaises(AttributeError): node.statement() - with self.assertRaises(AttributeError): - node.statement(False) with self.assertRaises(StatementMissing): node.statement(True) diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py index 118dea6d31..bab7817066 100644 --- a/tests/unittest_scoped_nodes.py +++ b/tests/unittest_scoped_nodes.py @@ -323,7 +323,6 @@ def test_default_value(self) -> None: def test_navigation(self) -> None: function = self.module["global_access"] self.assertEqual(function.statement(), function) - self.assertEqual(function.statement(False), function) self.assertEqual(function.statement(True), function) l_sibling = function.previous_sibling() # check taking parent if child is not a stmt @@ -823,7 +822,6 @@ def test_instance_special_attributes(self) -> None: def test_navigation(self) -> None: klass = self.module["YO"] self.assertEqual(klass.statement(), klass) - self.assertEqual(klass.statement(False), klass) self.assertEqual(klass.statement(True), klass) l_sibling = klass.previous_sibling() self.assertTrue(isinstance(l_sibling, nodes.FunctionDef), l_sibling) From 73fb21d6910abf0ac0410991b0250958b627a658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sat, 6 Nov 2021 18:33:08 +0200 Subject: [PATCH 15/21] Add tests --- tests/unittest_builder.py | 3 +++ tests/unittest_nodes.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/unittest_builder.py b/tests/unittest_builder.py index 662700a9d5..d9331ab674 100644 --- a/tests/unittest_builder.py +++ b/tests/unittest_builder.py @@ -615,6 +615,9 @@ def test_module_base_props(self) -> None: self.assertEqual(module.package, 0) self.assertFalse(module.is_statement) self.assertEqual(module.statement(), module) + with pytest.warns(DeprecationWarning) as warnings: + module.statement() + assert len(warnings) == 1 with self.assertRaises(StatementMissing): module.statement(True) diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py index 5f7cae67bf..e76f874db3 100644 --- a/tests/unittest_nodes.py +++ b/tests/unittest_nodes.py @@ -628,7 +628,9 @@ def _test(self, value: Any) -> None: self.assertTrue(node._proxied.parent) self.assertEqual(node._proxied.root().name, value.__class__.__module__) with self.assertRaises(AttributeError): - node.statement() + with pytest.warns(DeprecationWarning) as warnings: + node.statement() + assert len(warnings) == 1 with self.assertRaises(StatementMissing): node.statement(True) From 6777dc9c91767eb16cfd2c99addfc47ff665ef71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sat, 6 Nov 2021 18:50:34 +0100 Subject: [PATCH 16/21] Apply suggestions from code review Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- astroid/exceptions.py | 1 - astroid/nodes/node_ng.py | 2 +- tests/unittest_builder.py | 4 ++-- tests/unittest_nodes.py | 10 ++++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index d20a3706b4..8907d19458 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -265,7 +265,6 @@ class ParentMissingError(AstroidError): Standard attributes: target: The node for which the parent lookup failed. - missing_element: The type of attribute/method that is missing because of the missing parent """ def __init__(self, target: "nodes.NodeNG") -> None: diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 224f68548f..5e69029a24 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -274,7 +274,7 @@ def statement(self, future: Literal[True]) -> "nodes.Statement": ... def statement( - self, future: Literal[None, True] = None + self, *, future: Literal[None, True] = None ) -> Union["nodes.Statement", "nodes.Module", NoReturn]: """The first parent node, including self, marked as statement node. diff --git a/tests/unittest_builder.py b/tests/unittest_builder.py index d9331ab674..c25d82bcc0 100644 --- a/tests/unittest_builder.py +++ b/tests/unittest_builder.py @@ -615,9 +615,9 @@ def test_module_base_props(self) -> None: self.assertEqual(module.package, 0) self.assertFalse(module.is_statement) self.assertEqual(module.statement(), module) - with pytest.warns(DeprecationWarning) as warnings: + with pytest.warns(DeprecationWarning) as records: module.statement() - assert len(warnings) == 1 + assert len(records) == 1 with self.assertRaises(StatementMissing): module.statement(True) diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py index e76f874db3..15b9f67f49 100644 --- a/tests/unittest_nodes.py +++ b/tests/unittest_nodes.py @@ -627,10 +627,12 @@ def _test(self, value: Any) -> None: self.assertIs(node.value, value) self.assertTrue(node._proxied.parent) self.assertEqual(node._proxied.root().name, value.__class__.__module__) - with self.assertRaises(AttributeError): - with pytest.warns(DeprecationWarning) as warnings: - node.statement() - assert len(warnings) == 1 + with ( + self.assertRaises(AttributeError), + pytest.warns(DeprecationWarning) as records + ): + node.statement() + assert len(records) == 1 with self.assertRaises(StatementMissing): node.statement(True) From 1900532ebe0b940cde417e177713e932b3bce36b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sat, 6 Nov 2021 20:01:07 +0200 Subject: [PATCH 17/21] Code Review --- astroid/nodes/node_ng.py | 5 +++-- astroid/nodes/scoped_nodes.py | 5 +++-- tests/unittest_builder.py | 2 +- tests/unittest_nodes.py | 12 +++++------- tests/unittest_scoped_nodes.py | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 5e69029a24..d2a3186c15 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -291,12 +291,13 @@ def statement( raise StatementMissing(target=self) warnings.warn( "In astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement " - "or raise a StatementMissing exception. This behaviour can already be triggered " + "or raise a StatementMissing exception. AttributeError will no longer be raised. " + "This behaviour can already be triggered " "by passing 'future=True' to a statement() call.", DeprecationWarning, ) raise AttributeError(f"{self} object has no attribute 'parent'") - return self.parent.statement(future) + return self.parent.statement(future=future) def frame( self, diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index cde648fc2a..c9db043381 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -677,7 +677,8 @@ def statement( raise StatementMissing(target=self) warnings.warn( "In astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement " - "or raise a StatementMissing exception. This behaviour can already be triggered " + "or raise a StatementMissing exception. nodes.Module will no longer be " + "considered a statement. This behaviour can already be triggered " "by passing 'future=True' to a statement() call.", DeprecationWarning, ) @@ -2588,7 +2589,7 @@ def getattr(self, name, context=None, class_context=True): # Look for AnnAssigns, which are not attributes in the purest sense. for value in values: if isinstance(value, node_classes.AssignName): - stmt = value.statement(True) + stmt = value.statement() if isinstance(stmt, node_classes.AnnAssign) and stmt.value is None: raise AttributeInferenceError( target=self, attribute=name, context=context diff --git a/tests/unittest_builder.py b/tests/unittest_builder.py index c25d82bcc0..11019e1ba0 100644 --- a/tests/unittest_builder.py +++ b/tests/unittest_builder.py @@ -619,7 +619,7 @@ def test_module_base_props(self) -> None: module.statement() assert len(records) == 1 with self.assertRaises(StatementMissing): - module.statement(True) + module.statement(future=True) def test_module_locals(self) -> None: """test the 'locals' dictionary of an astroid module""" diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py index 15b9f67f49..10607fe1a8 100644 --- a/tests/unittest_nodes.py +++ b/tests/unittest_nodes.py @@ -627,14 +627,12 @@ def _test(self, value: Any) -> None: self.assertIs(node.value, value) self.assertTrue(node._proxied.parent) self.assertEqual(node._proxied.root().name, value.__class__.__module__) - with ( - self.assertRaises(AttributeError), - pytest.warns(DeprecationWarning) as records - ): - node.statement() - assert len(records) == 1 + with self.assertRaises(AttributeError): + with pytest.warns(DeprecationWarning) as records: + node.statement() + assert len(records) == 1 with self.assertRaises(StatementMissing): - node.statement(True) + node.statement(future=True) def test_none(self) -> None: self._test(None) diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py index bab7817066..db673629ff 100644 --- a/tests/unittest_scoped_nodes.py +++ b/tests/unittest_scoped_nodes.py @@ -323,7 +323,7 @@ def test_default_value(self) -> None: def test_navigation(self) -> None: function = self.module["global_access"] self.assertEqual(function.statement(), function) - self.assertEqual(function.statement(True), function) + self.assertEqual(function.statement(future=True), function) l_sibling = function.previous_sibling() # check taking parent if child is not a stmt self.assertIsInstance(l_sibling, nodes.Assign) @@ -822,7 +822,7 @@ def test_instance_special_attributes(self) -> None: def test_navigation(self) -> None: klass = self.module["YO"] self.assertEqual(klass.statement(), klass) - self.assertEqual(klass.statement(True), klass) + self.assertEqual(klass.statement(future=True), klass) l_sibling = klass.previous_sibling() self.assertTrue(isinstance(l_sibling, nodes.FunctionDef), l_sibling) self.assertEqual(l_sibling.name, "global_access") From 11aefd2567ece20d52f349c124961d0e5bf73585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sat, 6 Nov 2021 21:13:13 +0200 Subject: [PATCH 18/21] Added keyword parameter to all overloads and statements --- astroid/nodes/node_ng.py | 4 ++-- astroid/nodes/scoped_nodes.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index d2a3186c15..6fb242cd61 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -265,12 +265,12 @@ def parent_of(self, node): @overload def statement( - self, future: Literal[None] = ... + self, *, future: Literal[None] = ... ) -> Union["nodes.Statement", "nodes.Module"]: ... @overload - def statement(self, future: Literal[True]) -> "nodes.Statement": + def statement(self, *, future: Literal[True]) -> "nodes.Statement": ... def statement( diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index c9db043381..b9ebcb026d 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -653,17 +653,17 @@ def fully_defined(self): return self.file is not None and self.file.endswith(".py") @overload - def statement(self, future: Literal[None] = ...) -> "Module": + def statement(self, *, future: Literal[None] = ...) -> "Module": ... # pylint: disable-next=signature-differs # https://github.com/PyCQA/pylint/issues/5264 @overload - def statement(self, future: Literal[True]) -> NoReturn: + def statement(self, *, future: Literal[True]) -> NoReturn: ... def statement( - self, future: Literal[None, True] = None + self, *, future: Literal[None, True] = None ) -> Union[NoReturn, "Module"]: """The first parent node, including self, marked as statement node. From 2b6e7d0f296e4eb01068df6360443ac2da827b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sat, 6 Nov 2021 21:17:26 +0200 Subject: [PATCH 19/21] Add disable --- astroid/exceptions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index 8907d19458..b2c19080c3 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -282,6 +282,9 @@ class StatementMissing(ParentMissingError): """ def __init__(self, target: "nodes.NodeNG") -> None: + # See: https://github.com/PyCQA/pylint/issues/2903 + # and: https://github.com/PyCQA/astroid/pull/1217#discussion_r744149027 + # pylint: disable-next=bad-super-call super(ParentMissingError, self).__init__( message=f"Statement not found on {target!r}" ) From cab6a88476b5ace188580b633556cbfd30e3edfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sat, 6 Nov 2021 20:43:25 +0100 Subject: [PATCH 20/21] Update astroid/exceptions.py Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- astroid/exceptions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astroid/exceptions.py b/astroid/exceptions.py index b2c19080c3..b8838023e4 100644 --- a/astroid/exceptions.py +++ b/astroid/exceptions.py @@ -282,9 +282,9 @@ class StatementMissing(ParentMissingError): """ def __init__(self, target: "nodes.NodeNG") -> None: - # See: https://github.com/PyCQA/pylint/issues/2903 - # and: https://github.com/PyCQA/astroid/pull/1217#discussion_r744149027 # pylint: disable-next=bad-super-call + # https://github.com/PyCQA/pylint/issues/2903 + # https://github.com/PyCQA/astroid/pull/1217#discussion_r744149027 super(ParentMissingError, self).__init__( message=f"Statement not found on {target!r}" ) From 78588ff11003afce3a8b788a52dd6d61293e2562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sun, 7 Nov 2021 16:40:25 +0100 Subject: [PATCH 21/21] Update astroid/nodes/scoped_nodes.py Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- astroid/nodes/scoped_nodes.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index b9ebcb026d..df153b8875 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -656,8 +656,6 @@ def fully_defined(self): def statement(self, *, future: Literal[None] = ...) -> "Module": ... - # pylint: disable-next=signature-differs - # https://github.com/PyCQA/pylint/issues/5264 @overload def statement(self, *, future: Literal[True]) -> NoReturn: ...