From 27f1d0d75fc957c5adccd2c1ff16e2dcdd72891c Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Thu, 13 Jul 2023 08:44:48 -0400 Subject: [PATCH] Correct references to removed TryExcept node Follow-up to e91a3b5c9ceaf3171f0915cff95d40b9f05cfdee. --- ChangeLog | 1 - astroid/nodes/node_classes.py | 4 ++-- doc/api/astroid.nodes.rst | 7 ++----- tests/test_inference.py | 3 +-- tests/test_nodes_lineno.py | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8750167f89..16f98f25eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -121,7 +121,6 @@ Release date: TBA - ``nodes.Slice`` - ``nodes.Starred`` - ``objects.Super``, we also added the ``call`` parameter to its ``__init__`` method. - - ``nodes.TryExcept`` - ``nodes.Subscript`` - ``nodes.UnaryOp`` - ``nodes.While`` diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py index 80b30b79da..f22815555e 100644 --- a/astroid/nodes/node_classes.py +++ b/astroid/nodes/node_classes.py @@ -128,7 +128,7 @@ def are_exclusive(stmt1, stmt2, exceptions: list[str] | None = None) -> bool: algorithm : 1) index stmt1's parents 2) climb among stmt2's parents until we find a common parent - 3) if the common parent is a If or TryExcept statement, look if nodes are + 3) if the common parent is a If or Try statement, look if nodes are in exclusive branches """ # index stmt1's parents @@ -2542,7 +2542,7 @@ class ExceptHandler( print("Error!") ''') >>> node - + >>> node.handlers [] """ diff --git a/doc/api/astroid.nodes.rst b/doc/api/astroid.nodes.rst index 402002cc17..42177eaeff 100644 --- a/doc/api/astroid.nodes.rst +++ b/doc/api/astroid.nodes.rst @@ -76,8 +76,7 @@ Nodes astroid.nodes.Slice astroid.nodes.Starred astroid.nodes.Subscript - astroid.nodes.TryExcept - astroid.nodes.TryFinally + astroid.nodes.Try astroid.nodes.TryStar astroid.nodes.Tuple astroid.nodes.TypeAlias @@ -224,9 +223,7 @@ Nodes .. autoclass:: astroid.nodes.Subscript -.. autoclass:: astroid.nodes.TryExcept - -.. autoclass:: astroid.nodes.TryFinally +.. autoclass:: astroid.nodes.Try .. autoclass:: astroid.nodes.TryStar diff --git a/tests/test_inference.py b/tests/test_inference.py index 97bb1e1495..ce1f457165 100644 --- a/tests/test_inference.py +++ b/tests/test_inference.py @@ -6025,8 +6025,7 @@ def test_exception_lookup_last_except_handler_wins() -> None: assert isinstance(inferred_exc, Instance) assert inferred_exc.name == "OSError" - # Check that two except handlers on the same TryExcept works the same as separate - # TryExcepts + # Two except handlers on the same Try work the same as separate node = extract_node( """ try: diff --git a/tests/test_nodes_lineno.py b/tests/test_nodes_lineno.py index 09623c3a71..b0cdb9850b 100644 --- a/tests/test_nodes_lineno.py +++ b/tests/test_nodes_lineno.py @@ -737,7 +737,7 @@ def test_end_lineno_dict() -> None: @staticmethod def test_end_lineno_try() -> None: - """TryExcept, TryFinally, ExceptHandler.""" + """Try, ExceptHandler.""" code = textwrap.dedent( """ try: #@