Skip to content

Commit

Permalink
Fix deprecation warning for AssignAttr in tests (pylint-dev#5006)
Browse files Browse the repository at this point in the history
* Fix deprecation warning for AssignAttr

We should initialize nodes using their constructor

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
  • Loading branch information
Pierre-Sassoulas and cdce8p committed Sep 14, 2021
1 parent 272596b commit 8d3ced4
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/checkers/unittest_stdlib.py
Expand Up @@ -41,21 +41,18 @@ class TestStdlibChecker(CheckerTestCase):
CHECKER_CLASS = stdlib.StdlibChecker

def test_deprecated_no_qname_on_unexpected_nodes(self) -> None:
# Test that we don't crash on nodes which don't have
# a qname method. While this test might seem weird since
# it uses a transform, it's actually testing a crash that
# happened in production, but there was no way to retrieve
# the code for which this occurred (how an AssignAttr
# got to be the result of a function inference
# beats me..)
"""Test that we don't crash on nodes which don't have a qname method.
While this test might seem weird since it uses a transform, it's actually testing a crash
that happened in production, but there was no way to retrieve the code for which this
occurred (how an AssignAttr got to be the result of a function inference beats me..)"""

def infer_func(
node: Name, context: Optional[Any] = None
) -> Iterator[
Union[Iterator, Iterator[AssignAttr]]
]: # pylint: disable=unused-argument
new_node = nodes.AssignAttr()
new_node.parent = node
new_node = nodes.AssignAttr(attrname="alpha", parent=node)
yield new_node

manager = astroid.MANAGER
Expand Down

0 comments on commit 8d3ced4

Please sign in to comment.