Comments (5)
This is now an error with astroid >= 3
========================================================================= short test summary info ==========================================================================
FAILED tests/test_astroid.py::TestAstroid::test_complex_slice_and_parens - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_comprehensions - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture3 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture4 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture7 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture8 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture9 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fstrings - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_mark_tokens_multiline - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_mark_tokens_simple - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_parens_around_func - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_print_function - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_slices - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_sys_modules - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_trailing_commas - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_tuples - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?Details</summary>
``` python3.10 -m pytest =========================================================================== test session starts ============================================================================ platform linux -- Python 3.10.13, pytest-7.4.2, pluggy-1.2.0 benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000) rootdir: /var/tmp/paludis/build/dev-python-asttokens-2.4.0/work/PYTHON_ABIS/3.10/asttokens-2.4.0 configfile: setup.cfg plugins: flaky-3.7.0, expect-1.1.0, dependency-0.5.1, benchmark-4.0.0, services-2.2.1, anyio-3.6.2, django-4.5.2, forked-1.6.0, subtests-0.11.0, xdist-3.3.1, pytest_httpserver-1.0.8, cov-4.1.0, requests-mock-1.11.0, flake8-1.1.1, mock-3.11.1, asyncio-0.21.1, mypy-plugins-3.0.0, trio-0.8.0, hypothesis-6.86.2, xprocess-0.23.0, regressions-2.5.0, typeguard-4.1.5, datadir-1.5.0, pytest_param_files-0.6.0, sphinx_pytest-0.2.0, timeout-2.2.0, Faker-19.10.0, pyfakefs-5.3.0 asyncio: mode=strict collected 116 items
tests/test_astroid.py ..........FF..s.........FF..FFFF.FF....FF.F..FFF. [ 42%]
tests/test_asttokens.py ....... [ 48%]
tests/test_line_numbers.py ... [ 50%]
tests/test_mark_tokens.py ................................................. [ 93%]
tests/test_tokenless.py ... [ 95%]
tests/test_util.py ..... [100%]
================================================================================= FAILURES =================================================================================
________________________________________________________________ TestAstroid.test_complex_slice_and_parens _________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_complex_slice_and_parens>
def test_complex_slice_and_parens(self):
source = 'f((x)[:, 0])'
self.create_mark_checker(source)
tests/test_mark_tokens.py:624:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x738900d801c0>, node = <Tuple.tuple l.1 at 0x738900d839d0>
first_token = Token(type=54, string=':', start=(1, 6), end=(1, 7), line='f((x)[:, 0])', index=6, startpos=6, endpos=7)
last_token = Token(type=2, string='0', start=(1, 9), end=(1, 10), line='f((x)[:, 0])', index=8, startpos=9, endpos=10)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
_____________________________________________________________________ TestAstroid.test_comprehensions ______________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_comprehensions>
def test_comprehensions(self):
# See https://bitbucket.org/plas/thonny/issues/8/range-marker-doesnt-work-correctly-with
for source in (
"[(key, val) for key, val in ast.iter_fields(node)]",
"((key, val) for key, val in ast.iter_fields(node))",
"{(key, val) for key, val in ast.iter_fields(node)}",
"{key: val for key, val in ast.iter_fields(node)}",
"[[c for c in key] for key, val in ast.iter_fields(node)]"):
self.create_mark_checker(source)
tests/test_mark_tokens.py:396:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x738900c6f1f0>, node = <Tuple.tuple l.1 at 0x738900c6f610>
first_token = Token(type=54, string='(', start=(1, 1), end=(1, 2), line='[(key, val) for key, val in ast.iter_fields(node)]', index=1, startpos=1, endpos=2)
last_token = Token(type=54, string=')', start=(1, 10), end=(1, 11), line='[(key, val) for key, val in ast.iter_fields(node)]', index=5, startpos=10, endpos=11)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
________________________________________________________________________ TestAstroid.test_fixture3 _________________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_fixture3>
def test_fixture3(self): self.verify_fixture_file('astroid/all.py')
tests/test_mark_tokens.py:175:
tests/test_mark_tokens.py:139: in verify_fixture_file
m = self.create_mark_checker(source, verify=False)
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff55c2b0>, node = <Tuple.tuple l.9 at 0x7388ff5d6f80>
first_token = Token(type=3, string="'Aaa'", start=(9, 10), end=(9, 15), line="all = 'Aaa', '_bla', 'name'\n", index=32, startpos=85, endpos=90)
last_token = Token(type=3, string="'name'", start=(9, 25), end=(9, 31), line="all = 'Aaa', '_bla', 'name'\n", index=36, startpos=100, endpos=106)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
________________________________________________________________________ TestAstroid.test_fixture4 _________________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_fixture4>
def test_fixture4(self): self.verify_fixture_file('astroid/clientmodule_test.py')
tests/test_mark_tokens.py:176:
tests/test_mark_tokens.py:139: in verify_fixture_file
m = self.create_mark_checker(source, verify=False)
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff3906a0>, node = <Tuple.tuple l.8 at 0x7388ff3923b0>
first_token = Token(type=54, string='(', start=(8, 21), end=(8, 22), line=' implements = (IFace,)\n', index=29, startpos=194, endpos=195)
last_token = Token(type=54, string=')', start=(8, 28), end=(8, 29), line=' implements = (IFace,)\n', index=32, startpos=201, endpos=202)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
________________________________________________________________________ TestAstroid.test_fixture7 _________________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_fixture7>
def test_fixture7(self): self.verify_fixture_file('astroid/format.py')
tests/test_mark_tokens.py:179:
tests/test_mark_tokens.py:139: in verify_fixture_file
m = self.create_mark_checker(source, verify=False)
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff426e90>, node = <Tuple.tuple l.26 at 0x7388ff426aa0>
first_token = Token(type=1, string='aaaa', start=(26, 4), end=(26, 8), line=' aaaa,bbbb = 1,2\n', index=93, startpos=320, endpos=324)
last_token = Token(type=1, string='bbbb', start=(26, 9), end=(26, 13), line=' aaaa,bbbb = 1,2\n', index=95, startpos=325, endpos=329)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
________________________________________________________________________ TestAstroid.test_fixture8 _________________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_fixture8>
def test_fixture8(self): self.verify_fixture_file('astroid/module.py')
tests/test_mark_tokens.py:180:
tests/test_mark_tokens.py:139: in verify_fixture_file
m = self.create_mark_checker(source, verify=False)
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x738901942800>, node = <Tuple.tuple l.34 at 0x7388ff3976a0>
first_token = Token(type=54, string='(', start=(34, 15), end=(34, 16), line=' except (NameError, TypeError):\n', index=143, startpos=631, endpos=632)
last_token = Token(type=54, string=')', start=(34, 36), end=(34, 37), line=' except (NameError, TypeError):\n', index=147, startpos=652, endpos=653)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
________________________________________________________________________ TestAstroid.test_fixture9 _________________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_fixture9>
def test_fixture9(self): self.verify_fixture_file('astroid/module2.py')
tests/test_mark_tokens.py:181:
tests/test_mark_tokens.py:139: in verify_fixture_file
m = self.create_mark_checker(source, verify=False)
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff281e70>, node = <Tuple.tuple l.58 at 0x7388ff55d5d0>
first_token = Token(type=54, string='(', start=(58, 21), end=(58, 22), line=' implements = (MyIFace, AnotherIFace)\n', index=183, startpos=620, endpos=621)
last_token = Token(type=54, string=')', start=(58, 43), end=(58, 44), line=' implements = (MyIFace, AnotherIFace)\n', index=187, startpos=642, endpos=643)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
________________________________________________________________________ TestAstroid.test_fstrings _________________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_fstrings>
def test_fstrings(self):
for source in (
'(f"He said his name is {name!r}.",)',
"f'{function(kwarg=24)}'",
'a = f"""result: {value:{width}.{precision}}"""',
"""[f"abc {a['x']} def"]""",
"def t():\n return f'{function(kwarg=24)}'"):
self.create_mark_checker(source)
tests/test_mark_tokens.py:316:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff5cc130>, node = <Tuple.tuple l.1 at 0x7388ff5cd960>
first_token = Token(type=54, string='(', start=(1, 0), end=(1, 1), line='(f"He said his name is {name!r}.",)', index=0, startpos=0, endpos=1)
last_token = Token(type=54, string=')', start=(1, 34), end=(1, 35), line='(f"He said his name is {name!r}.",)', index=3, startpos=34, endpos=35)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
__________________________________________________________________ TestAstroid.test_mark_tokens_multiline __________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_mark_tokens_multiline>
def test_mark_tokens_multiline(self):
source = (
"""( # line1
a, # line2
b + # line3
c + # line4
d # line5
)""")
m = self.create_mark_checker(source)
tests/test_mark_tokens.py:117:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff454c40>, node = <Tuple.tuple l.1 at 0x738900d836d0>
first_token = Token(type=54, string='(', start=(1, 0), end=(1, 1), line='( # line1\n', index=0, startpos=0, endpos=1)
last_token = Token(type=54, string=')', start=(6, 0), end=(6, 1), line=')', index=18, startpos=77, endpos=78)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
___________________________________________________________________ TestAstroid.test_mark_tokens_simple ____________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_mark_tokens_simple>
def test_mark_tokens_simple(self):
source = tools.read_fixture('astroid', 'module.py')
m = self.create_mark_checker(source)
tests/test_mark_tokens.py:79:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff6255d0>, node = <Tuple.tuple l.34 at 0x7388ff624bb0>
first_token = Token(type=54, string='(', start=(34, 15), end=(34, 16), line=' except (NameError, TypeError):\n', index=143, startpos=631, endpos=632)
last_token = Token(type=54, string=')', start=(34, 36), end=(34, 37), line=' except (NameError, TypeError):\n', index=147, startpos=652, endpos=653)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
___________________________________________________________________ TestAstroid.test_parens_around_func ____________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_parens_around_func>
def test_parens_around_func(self):
source = textwrap.dedent(
'''
foo()
(foo)()
(lambda: 0)()
(lambda: ())()
(foo)((1))
(lambda: ())((2))
x = (obj.attribute.get_callback() or default_callback)()
''')
m = self.create_mark_checker(source)
tests/test_mark_tokens.py:610:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff63cf10>, node = <Tuple.tuple l.5 at 0x7388ff29c100>
first_token = Token(type=54, string='(', start=(5, 9), end=(5, 10), line='(lambda: ())()\n', index=22, startpos=38, endpos=39)
last_token = Token(type=54, string=')', start=(5, 10), end=(5, 11), line='(lambda: ())()\n', index=23, startpos=39, endpos=40)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
_____________________________________________________________________ TestAstroid.test_print_function ______________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_print_function>
def test_print_function(self):
# This testcase imports print as function (using from __future__). Check that we can parse it.
# verify_all_nodes doesn't work on Python 2 because the print() call parsed in isolation
# is viewed as a Print node since it doesn't see the future import
source = tools.read_fixture('astroid/nonregr.py')
m = self.create_mark_checker(source, verify=six.PY3)
tests/test_mark_tokens.py:278:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff300250>, node = <Tuple.tuple l.11 at 0x7388ff34bc70>
first_token = Token(type=1, string='i', start=(11, 18), end=(11, 19), line=' yield i, val\n', index=39, startpos=200, endpos=201)
last_token = Token(type=1, string='val', start=(11, 21), end=(11, 24), line=' yield i, val\n', index=41, startpos=203, endpos=206)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
_________________________________________________________________________ TestAstroid.test_slices __________________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_slices>
def test_slices(self):
# Make sure we don't fail on parsing slices of the form `foo[4:]`.
source = "(foo.Area_Code, str(foo.Phone)[:3], str(foo.Phone)[3:], foo[:], bar[::2, :], bar2[:, ::2], [a[:]][::-1])"
m = self.create_mark_checker(source)
tests/test_mark_tokens.py:239:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff29d960>, node = <Tuple.tuple l.1 at 0x7388ff1b18a0>
first_token = Token(type=54, string=':', start=(1, 68), end=(1, 69), line='(foo.Area_Code, str(foo.Phone)[:3], str(foo.Phone)[3:], foo[:], bar[::2, :], bar2[:, ::2], [a[:]][::-1])', index=34, startpos=68, endpos=69)
last_token = Token(type=2, string='2', start=(1, 70), end=(1, 71), line='(foo.Area_Code, str(foo.Phone)[:3], str(foo.Phone)[3:], foo[:], bar[::2, :], bar2[:, ::2], [a[:]][::-1])', index=36, startpos=70, endpos=71)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
_______________________________________________________________________ TestAstroid.test_sys_modules _______________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_sys_modules>
def test_sys_modules(self):
"""
Verify all nodes on source files obtained from sys.modules.
This can take a long time as there are many modules,
so it only tests all modules if the environment variable
ASTTOKENS_SLOW_TESTS has been set.
"""
from .test_astroid import AstroidTreeException
modules = list(sys.modules.values())
if not os.environ.get('ASTTOKENS_SLOW_TESTS'):
modules = modules[:20]
start = time()
for module in modules:
# Don't let this test (which runs twice) take longer than 13 minutes
# to avoid the travis build time limit of 30 minutes
if time() - start > 13 * 60:
break
try:
filename = inspect.getsourcefile(module)
except Exception: # some modules raise weird errors
continue
if not filename:
continue
filename = os.path.abspath(filename)
print(filename)
try:
with io.open(filename) as f:
source = f.read()
except OSError:
continue
if self.is_astroid_test and (
# Astroid fails with a syntax error if a type comment is on its own line
re.search(r'^\s*# type: ', source, re.MULTILINE)
):
print('Skipping', filename)
continue
try:
self.create_mark_checker(source)
tests/test_mark_tokens.py:671:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388fc6caec0>, node = <Tuple.tuple l.247 at 0x7388fc6c8c40>
first_token = Token(type=54, string='(', start=(247, 34), end=(247, 35), line=" if not message.startswith(('#', 'import ')):\n", index=1130, startpos=7717, endpos=7718)
last_token = Token(type=54, string=')', start=(247, 49), end=(247, 50), line=" if not message.startswith(('#', 'import ')):\n", index=1134, startpos=7732, endpos=7733)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
/usr/lib/python3.10/importlib/_bootstrap.py
_____________________________________________________________________ TestAstroid.test_trailing_commas _____________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_trailing_commas>
def test_trailing_commas(self):
# Make sure we handle trailing commas on comma-separated structures (e.g. tuples, sets, etc.)
for source in (
"(a,b,)",
"[c,d,]",
"{e,f,}",
"{h:1,i:2,}"):
self.create_mark_checker(source)
tests/test_mark_tokens.py:405:
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388fbbbf940>, node = <Tuple.tuple l.1 at 0x7388fbbbfd90>
first_token = Token(type=54, string='(', start=(1, 0), end=(1, 1), line='(a,b,)', index=0, startpos=0, endpos=1)
last_token = Token(type=54, string=')', start=(1, 5), end=(1, 6), line='(a,b,)', index=5, startpos=5, endpos=6)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
_________________________________________________________________________ TestAstroid.test_tuples __________________________________________________________________________
self = <tests.test_astroid.TestAstroid testMethod=test_tuples>
def test_tuples(self):
def get_tuples(code):
m = self.create_mark_checker(code)
return [m.atok.get_text(n) for n in m.all_nodes if n.__class__.__name__ == "Tuple"]
self.assertEqual(get_tuples("a,"), ["a,"])
tests/test_mark_tokens.py:412:
tests/test_mark_tokens.py:409: in get_tuples
m = self.create_mark_checker(code)
tests/test_mark_tokens.py:38: in create_mark_checker
atok = self.create_asttokens(source)
tests/test_astroid.py:42: in create_asttokens
return ASTTokens(source, tree=tree)
asttokens/asttokens.py:130: in init
self.mark_tokens(self._tree)
asttokens/asttokens.py:142: in mark_tokens
MarkTokens(self).visit_tree(root_node)
asttokens/mark_tokens.py:61: in visit_tree
util.visit_tree(node, self._visit_before_children, self._visit_after_children)
asttokens/util.py:272: in visit_tree
ret = postvisit(current, par_value, cast(Optional[Token], value))
asttokens/mark_tokens.py:109: in _visit_after_children
nfirst, nlast = self._methods.get(self, node.class)(node, first, last)
self = <asttokens.mark_tokens.MarkTokens object at 0x7388ff563c40>, node = <Tuple.tuple l.1 at 0x7388ff562f20>
first_token = Token(type=1, string='a', start=(1, 0), end=(1, 1), line='a,', index=0, startpos=0, endpos=1)
last_token = Token(type=1, string='a', start=(1, 0), end=(1, 1), line='a,', index=0, startpos=0, endpos=1)
def visit_tuple(self, node, first_token, last_token):
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
assert isinstance(node, ast.Tuple) or isinstance(node, nc._BaseContainer)
E AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
asttokens/mark_tokens.py:334: AttributeError
========================================================================= short test summary info ==========================================================================
FAILED tests/test_astroid.py::TestAstroid::test_complex_slice_and_parens - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_comprehensions - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture3 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture4 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture7 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture8 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fixture9 - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_fstrings - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_mark_tokens_multiline - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_mark_tokens_simple - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_parens_around_func - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_print_function - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_slices - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_sys_modules - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_trailing_commas - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
FAILED tests/test_astroid.py::TestAstroid::test_tuples - AttributeError: module 'astroid.nodes' has no attribute '_BaseContainer'. Did you mean: 'BaseContainer'?
================================================================= 16 failed, 99 passed, 1 skipped in 5.69s =================================================================
</p>
</details>
from asttokens.
module 'astroid.nodes' has no attribute '_BaseContainer'
is because _BaseContainer
got renamed, not because of using astroid.node_classes
.
PR welcome to add _BaseContainer
/ BaseContainer
to astroid_compat.py.
from asttokens.
After the rename of _BaseContainer
, there's three tests which still fail. One looks like a count of the nodes touched, which has a comment that the exact number isn't important, so that's easy to fix.
The others look like they're a result of a change in behaviour:
____________________ TestAstroid.test_fixture9 ____________________
self = <tests.test_astroid.TestAstroid testMethod=test_fixture9>
> def test_fixture9(self): self.verify_fixture_file('astroid/module2.py')
tests/test_mark_tokens.py:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_mark_tokens.py:140: in verify_fixture_file
tested_nodes = m.verify_all_nodes(self)
tests/tools.py:89: in verify_all_nodes
self.check_get_text_tokenless(node, test_case, text)
tests/tools.py:160: in check_get_text_tokenless
test_case.assertEqual(text, text_tokenless)
E AssertionError: 'class Aaaa(base):' != ' class Aaaa(base):\n """dynamic class"""'
E - class Aaaa(base):
E + class Aaaa(base):
E """dynamic class"""
@alexmojaki what's the expected outcome here -- is this the sort of thing where you'd update the test expectation, or does this imply that code changes are needed to preserve the previous behaviour? (I haven't yet looked much into what the test actually does).
from asttokens.
Nevermind, I think I have fixes (somewhat accidentally) from fixing some of the warnings.
from asttokens.
Released 2.4.1
from asttokens.
Related Issues (20)
- ASTText astroid support HOT 1
- IndexError in asttokens.ASTTokens HOT 2
- Timelines around support for legacy Python HOT 2
- Replace deprecated imp module with importlib HOT 2
- Compatibility with Python 3.12 and unreleased astroid 3.0.0 HOT 1
- Drop Python 2.7? HOT 4
- CI is absurdly slow HOT 8
- ModuleNotFoundError: No module named 'six.moves' with python 3.12 HOT 5
- RFE: is it possible to start making github releases?🤔
- ASTText: Module found error HOT 5
- 2.4.1 + master (ab2c6289): pytest fails in tests/test_astroid.py and tests/test_mark_tokens.py units HOT 3
- 2.4.1: sphinx warnings `reference target not found`
- 2.0.5: pytest is failing in few `astroid` units HOT 15
- `asttokens` 2.0.6 has undeclared dependency on `astroid` HOT 8
- Followup to astroid import fix
- mypy reports `error: Name "asttokens.ASTTokens" is not defined` HOT 4
- Support for constructing around a list of existing tokens HOT 6
- Docs outdated HOT 3
- Consider a clearer optional-functionality API HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asttokens.