Closed
Description
With current astroid (version 2.4.2) we are experiencing 4 test failures when running with Python 3.9.0. Sadly, I don't see into astroid, hence I couldn't find the root cause, but I am ready to help with debugging.
________________________ TypingBrain.test_namedtuple_few_args ________________________
self = <tests.unittest_brain.TypingBrain testMethod=test_namedtuple_few_args>
def test_namedtuple_few_args(self):
result = builder.extract_node(
"""
from typing import NamedTuple
NamedTuple("A")
"""
)
inferred = next(result.infer())
> self.assertIsInstance(inferred, astroid.Instance)
E AssertionError: Uninferable is not an instance of <class 'astroid.bases.Instance'>
tests/unittest_brain.py:1021: AssertionError
_______________________ TypingBrain.test_namedtuple_few_fields _______________________
self = <tests.unittest_brain.TypingBrain testMethod=test_namedtuple_few_fields>
def test_namedtuple_few_fields(self):
result = builder.extract_node(
"""
from typing import NamedTuple
NamedTuple("A", [("a",), ("b", str), ("c", bytes)])
"""
)
inferred = next(result.infer())
> self.assertIsInstance(inferred, astroid.Instance)
E AssertionError: Uninferable is not an instance of <class 'astroid.bases.Instance'>
tests/unittest_brain.py:1032: AssertionError
__________________ TypingBrain.test_namedtuple_inference_nonliteral __________________
self = <tests.unittest_brain.TypingBrain testMethod=test_namedtuple_inference_nonliteral>
def test_namedtuple_inference_nonliteral(self):
# Note: NamedTuples in mypy only work with literals.
klass = builder.extract_node(
"""
from typing import NamedTuple
name = "X"
fields = [("a", int), ("b", str), ("c", bytes)]
NamedTuple(name, fields)
"""
)
inferred = next(klass.infer())
> self.assertIsInstance(inferred, astroid.Instance)
E AssertionError: Uninferable is not an instance of <class 'astroid.bases.Instance'>
tests/unittest_brain.py:988: AssertionError
________________ test_dataclasses_subscript_inference_recursion_error ________________
@pytest.mark.skipif(sys.version_info < (3, 8), reason="Needs dataclasses available")
def test_dataclasses_subscript_inference_recursion_error():
code = """
from dataclasses import dataclass, replace
@dataclass
class ProxyConfig:
auth: str = "/auth"
a = ProxyConfig("")
test_dict = {"proxy" : {"auth" : "", "bla" : "f"}}
foo = test_dict['proxy']
replace(a, **test_dict['proxy']) # This fails
"""
node = extract_node(code)
# Reproduces only with safe_infer()
> assert helpers.safe_infer(node) is None
E assert Uninferable is None
E + where Uninferable = <function safe_infer at 0x7fca603b4040>(<Call l.13 at 0x7fca4e6fc1f0>)
E + where <function safe_infer at 0x7fca603b4040> = helpers.safe_infer
tests/unittest_inference.py:5691: AssertionError
====== 4 failed, 908 passed, 6 skipped, 14 xfailed, 1 xpassed in 35.69 seconds =======