Open
Description
Steps to reproduce
tox -e py312
. .tox/py312/bin/activate
pip install numpy==2.0.0rc2
pytest
Current behavior
FAILED tests/brain/numpy/test_core_einsumfunc.py::test_numpy_function_calls_inferred_as_ndarray - AssertionError: Illicit type for einsum (Uninferable)
FAILED tests/brain/numpy/test_core_fromnumeric.py::BrainNumpyCoreFromNumericTest::test_numpy_function_calls_inferred_as_ndarray - AssertionError: False is not true : Illicit type for sum (Uninferable)
FAILED tests/brain/numpy/test_core_multiarray.py::BrainNumpyCoreMultiarrayTest::test_numpy_function_calls_inferred_as_ndarray - AssertionError: False is not true : Illicit type for inner (builtins.tuple)
FAILED tests/brain/numpy/test_core_numerictypes.py::NumpyBrainCoreNumericTypesTest::test_datetime_astype_return - TypeError: 'in <string>' requires string as left operand, not UninferableBase
FAILED tests/brain/numpy/test_core_numerictypes.py::NumpyBrainCoreNumericTypesTest::test_generic_types_are_subscriptables - AssertionError: Uninferable is not an instance of <class 'astroid.nodes.scoped_nodes.scoped_nodes.ClassDef'>
FAILED tests/brain/numpy/test_core_umath.py::NumpyBrainCoreUmathTest::test_numpy_core_umath_functions_return_type - AssertionError: False is not true : Illicit type for arccos (Uninferable)
FAILED tests/brain/numpy/test_core_umath.py::NumpyBrainCoreUmathTest::test_numpy_core_umath_functions_return_type_tuple - AssertionError: False is not true : Illicit type for frexp (Uninferable)
FAILED tests/test_regrtest.py::NonRegressionTests::test_numpy_distutils - AssertionError: Uninferable is not an instance of <class 'astroid.nodes.node_classes.Const'>
Full log with tracebacks
$ pytest
========================================================= test session starts =========================================================
platform linux -- Python 3.12.3, pytest-8.2.0, pluggy-1.5.0
rootdir: /tmp/astroid
configfile: pyproject.toml
testpaths: tests
plugins: cov-5.0.0
collected 1688 items
tests/brain/numpy/test_core_einsumfunc.py F. [ 0%]
tests/brain/numpy/test_core_fromnumeric.py F [ 0%]
tests/brain/numpy/test_core_function_base.py . [ 0%]
tests/brain/numpy/test_core_multiarray.py ..F.. [ 0%]
tests/brain/numpy/test_core_numeric.py ..... [ 0%]
tests/brain/numpy/test_core_numerictypes.py .FF....ss [ 1%]
tests/brain/numpy/test_core_umath.py .....FF. [ 1%]
tests/brain/numpy/test_ma.py .... [ 2%]
tests/brain/numpy/test_ndarray.py ... [ 2%]
tests/brain/numpy/test_random_mtrand.py .. [ 2%]
tests/brain/test_argparse.py . [ 2%]
tests/brain/test_attr.py ..... [ 2%]
tests/brain/test_brain.py .s.....s....ss...........................................s........................................... [ 8%]
...............x...................... [ 10%]
tests/brain/test_builtin.py .................. [ 12%]
tests/brain/test_ctypes.py ....x........................ [ 13%]
tests/brain/test_dataclasses.py ..............................................................................x... [ 18%]
tests/brain/test_dateutil.py . [ 18%]
tests/brain/test_enum.py ............................. [ 20%]
tests/brain/test_hashlib.py ... [ 20%]
tests/brain/test_multiprocessing.py ... [ 20%]
tests/brain/test_named_tuple.py ....................... [ 22%]
tests/brain/test_nose.py s [ 22%]
tests/brain/test_pathlib.py .... [ 22%]
tests/brain/test_pytest.py . [ 22%]
tests/brain/test_qt.py sss [ 22%]
tests/brain/test_regex.py .X [ 22%]
tests/brain/test_signal.py ... [ 22%]
tests/brain/test_six.py ....... [ 23%]
tests/brain/test_ssl.py . [ 23%]
tests/brain/test_threading.py .... [ 23%]
tests/brain/test_typing.py . [ 23%]
tests/brain/test_typing_extensions.py . [ 23%]
tests/brain/test_unittest.py . [ 23%]
tests/test_builder.py .......................................................x.. [ 27%]
tests/test_constraint.py ................................... [ 29%]
tests/test_decorators.py ... [ 29%]
tests/test_filter_statements.py . [ 29%]
tests/test_group_exceptions.py ... [ 29%]
tests/test_helpers.py ............... [ 30%]
tests/test_inference.py ..........................................................................................x...........x [ 36%]
.....x.........................................................x............................................................... [ 44%]
..........................................................................x........xx.....................x...x................ [ 51%]
..........................s......x........................................ [ 56%]
tests/test_inference_calls.py ........................ [ 57%]
tests/test_lookup.py ....................................................... [ 60%]
tests/test_manager.py ............................................ [ 63%]
tests/test_modutils.py ................................................................... [ 67%]
tests/test_nodes.py ........................................................................................................... [ 73%]
................................................................................. [ 78%]
tests/test_nodes_lineno.py s....................... [ 79%]
tests/test_nodes_position.py ... [ 80%]
tests/test_object_model.py x...............x.........s......... [ 82%]
tests/test_objects.py ...................... [ 83%]
tests/test_protocols.py ..................... [ 84%]
tests/test_python3.py .......................... [ 86%]
tests/test_raw_building.py ............. [ 87%]
tests/test_regrtest.py ..............F........... [ 88%]
tests/test_scoped_nodes.py .................................................................................................... [ 94%]
................................................................... [ 98%]
tests/test_stdlib.py .. [ 98%]
tests/test_transforms.py ......... [ 99%]
tests/test_type_params.py ..... [ 99%]
tests/test_utils.py ........ [100%]
============================================================== FAILURES ===============================================================
____________________________________________ test_numpy_function_calls_inferred_as_ndarray ____________________________________________
@pytest.mark.skipif(not HAS_NUMPY, reason="This test requires the numpy library.")
def test_numpy_function_calls_inferred_as_ndarray() -> None:
"""Test that calls to numpy functions are inferred as numpy.ndarray."""
method = "einsum"
inferred_values = list(
_inferred_numpy_func_call(method, "ii, np.arange(25).reshape(5, 5)")
)
assert len(inferred_values) == 1, f"Too much inferred value for {method:s}"
> assert (
inferred_values[-1].pytype() == ".ndarray"
), f"Illicit type for {method:s} ({inferred_values[-1].pytype()})"
E AssertionError: Illicit type for einsum (Uninferable)
E assert Uninferable == '.ndarray'
E + where Uninferable = Uninferable()
E + where Uninferable = Uninferable.pytype
tests/brain/numpy/test_core_einsumfunc.py:39: AssertionError
_____________________________ BrainNumpyCoreFromNumericTest.test_numpy_function_calls_inferred_as_ndarray _____________________________
self = <tests.brain.numpy.test_core_fromnumeric.BrainNumpyCoreFromNumericTest testMethod=test_numpy_function_calls_inferred_as_ndarray>
def test_numpy_function_calls_inferred_as_ndarray(self):
"""Test that calls to numpy functions are inferred as numpy.ndarray."""
licit_array_types = (".ndarray",)
for func_ in self.numpy_functions:
with self.subTest(typ=func_):
inferred_values = list(self._inferred_numpy_func_call(*func_))
self.assertTrue(
len(inferred_values) == 1,
msg=f"Too much inferred value for {func_[0]:s}",
)
> self.assertTrue(
inferred_values[-1].pytype() in licit_array_types,
msg=f"Illicit type for {func_[0]:s} ({inferred_values[-1].pytype()})",
)
E AssertionError: False is not true : Illicit type for sum (Uninferable)
tests/brain/numpy/test_core_fromnumeric.py:43: AssertionError
_____________________________ BrainNumpyCoreMultiarrayTest.test_numpy_function_calls_inferred_as_ndarray ______________________________
self = <tests.brain.numpy.test_core_multiarray.BrainNumpyCoreMultiarrayTest testMethod=test_numpy_function_calls_inferred_as_ndarray>
def test_numpy_function_calls_inferred_as_ndarray(self):
"""Test that calls to numpy functions are inferred as numpy.ndarray."""
for infer_wrapper in (
self._inferred_numpy_func_call,
self._inferred_numpy_no_alias_func_call,
):
for func_ in self.numpy_functions_returning_array:
with self.subTest(typ=func_):
inferred_values = list(infer_wrapper(*func_))
self.assertTrue(
len(inferred_values) == 1,
msg="Too much inferred values ({}) for {:s}".format(
inferred_values, func_[0]
),
)
> self.assertTrue(
inferred_values[-1].pytype() == ".ndarray",
msg="Illicit type for {:s} ({})".format(
func_[0], inferred_values[-1].pytype()
),
)
E AssertionError: False is not true : Illicit type for inner (builtins.tuple)
tests/brain/numpy/test_core_multiarray.py:97: AssertionError
_____________________________________ NumpyBrainCoreNumericTypesTest.test_datetime_astype_return ______________________________________
self = <tests.brain.numpy.test_core_numerictypes.NumpyBrainCoreNumericTypesTest testMethod=test_datetime_astype_return>
def test_datetime_astype_return(self):
"""
Test that the return of astype method of the datetime object
is inferred as a ndarray.
pylint-dev/pylint#3332
"""
node = builder.extract_node(
"""
import numpy as np
import datetime
test_array = np.datetime64(1, 'us')
test_array.astype(datetime.datetime)
"""
)
licit_array_types = ".ndarray"
inferred_values = list(node.infer())
self.assertTrue(
len(inferred_values) == 1,
msg="Too much inferred value for datetime64.astype",
)
self.assertTrue(
> inferred_values[-1].pytype() in licit_array_types,
msg="Illicit type for {:s} ({})".format(
"datetime64.astype", inferred_values[-1].pytype()
),
)
E TypeError: 'in <string>' requires string as left operand, not UninferableBase
tests/brain/numpy/test_core_numerictypes.py:329: TypeError
________________________________ NumpyBrainCoreNumericTypesTest.test_generic_types_are_subscriptables _________________________________
self = <tests.brain.numpy.test_core_numerictypes.NumpyBrainCoreNumericTypesTest testMethod=test_generic_types_are_subscriptables>
@unittest.skipUnless(
HAS_NUMPY and numpy_supports_type_hints(),
f"This test requires the numpy library with a version above {NUMPY_VERSION_TYPE_HINTS_SUPPORT}",
)
def test_generic_types_are_subscriptables(self):
"""Test that all types deriving from generic are subscriptables."""
for type_ in (
"bool_",
"bytes_",
"character",
"complex128",
"complex192",
"complex64",
"complexfloating",
"datetime64",
"flexible",
"float16",
"float32",
"float64",
"float96",
"floating",
"generic",
"inexact",
"int16",
"int32",
"int32",
"int64",
"int8",
"integer",
"number",
"signedinteger",
"str_",
"timedelta64",
"uint16",
"uint32",
"uint32",
"uint64",
"uint8",
"unsignedinteger",
"void",
):
with self.subTest(type_=type_):
src = f"""
import numpy as np
np.{type_}[int]
"""
node = builder.extract_node(src)
cls_node = node.inferred()[0]
> self.assertIsInstance(cls_node, nodes.ClassDef)
E AssertionError: Uninferable is not an instance of <class 'astroid.nodes.scoped_nodes.scoped_nodes.ClassDef'>
tests/brain/numpy/test_core_numerictypes.py:383: AssertionError
_________________________________ NumpyBrainCoreUmathTest.test_numpy_core_umath_functions_return_type _________________________________
self = <tests.brain.numpy.test_core_umath.NumpyBrainCoreUmathTest testMethod=test_numpy_core_umath_functions_return_type>
def test_numpy_core_umath_functions_return_type(self):
"""Test that functions which should return a ndarray do return it."""
ndarray_returning_func = [
f for f in self.all_ufunc if f not in ("frexp", "modf")
]
for func_ in ndarray_returning_func:
with self.subTest(typ=func_):
inferred_values = list(self._inferred_numpy_func_call(func_))
self.assertTrue(
len(inferred_values) == 1,
msg="Too much inferred values ({}) for {:s}".format(
inferred_values[-1].pytype(), func_
),
)
> self.assertTrue(
inferred_values[0].pytype() == ".ndarray",
msg=f"Illicit type for {func_:s} ({inferred_values[-1].pytype()})",
)
E AssertionError: False is not true : Illicit type for arccos (Uninferable)
tests/brain/numpy/test_core_umath.py:209: AssertionError
______________________________ NumpyBrainCoreUmathTest.test_numpy_core_umath_functions_return_type_tuple ______________________________
self = <tests.brain.numpy.test_core_umath.NumpyBrainCoreUmathTest testMethod=test_numpy_core_umath_functions_return_type_tuple>
def test_numpy_core_umath_functions_return_type_tuple(self):
"""Test that functions which should return a pair of ndarray do return it."""
ndarray_returning_func = ("frexp", "modf")
for func_ in ndarray_returning_func:
with self.subTest(typ=func_):
inferred_values = list(self._inferred_numpy_func_call(func_))
self.assertTrue(
len(inferred_values) == 1,
msg=f"Too much inferred values ({inferred_values}) for {func_:s}",
)
> self.assertTrue(
inferred_values[-1].pytype() == "builtins.tuple",
msg=f"Illicit type for {func_:s} ({inferred_values[-1].pytype()})",
)
E AssertionError: False is not true : Illicit type for frexp (Uninferable)
tests/brain/numpy/test_core_umath.py:225: AssertionError
_______________________________________________ NonRegressionTests.test_numpy_distutils _______________________________________________
self = <tests.test_regrtest.NonRegressionTests testMethod=test_numpy_distutils>
@unittest.skipUnless(HAS_NUMPY, "Needs numpy")
def test_numpy_distutils(self):
"""Special handling of virtualenv's patching of distutils shouldn't interfere
with numpy.distutils.
PY312_PLUS -- This test will likely become unnecessary when Python 3.12 is
numpy's minimum version. (numpy.distutils will be removed then.)
"""
node = extract_node(
"""
from numpy.distutils.misc_util import is_sequence
is_sequence("ABC") #@
"""
)
inferred = node.inferred()
> self.assertIsInstance(inferred[0], nodes.Const)
E AssertionError: Uninferable is not an instance of <class 'astroid.nodes.node_classes.Const'>
tests/test_regrtest.py:118: AssertionError
======================================================= short test summary info =======================================================
FAILED tests/brain/numpy/test_core_einsumfunc.py::test_numpy_function_calls_inferred_as_ndarray - AssertionError: Illicit type for einsum (Uninferable)
FAILED tests/brain/numpy/test_core_fromnumeric.py::BrainNumpyCoreFromNumericTest::test_numpy_function_calls_inferred_as_ndarray - AssertionError: False is not true : Illicit type for sum (Uninferable)
FAILED tests/brain/numpy/test_core_multiarray.py::BrainNumpyCoreMultiarrayTest::test_numpy_function_calls_inferred_as_ndarray - AssertionError: False is not true : Illicit type for inner (builtins.tuple)
FAILED tests/brain/numpy/test_core_numerictypes.py::NumpyBrainCoreNumericTypesTest::test_datetime_astype_return - TypeError: 'in <string>' requires string as left operand, not UninferableBase
FAILED tests/brain/numpy/test_core_numerictypes.py::NumpyBrainCoreNumericTypesTest::test_generic_types_are_subscriptables - AssertionError: Uninferable is not an instance of <class 'astroid.nodes.scoped_nodes.scoped_nodes.ClassDef'>
FAILED tests/brain/numpy/test_core_umath.py::NumpyBrainCoreUmathTest::test_numpy_core_umath_functions_return_type - AssertionError: False is not true : Illicit type for arccos (Uninferable)
FAILED tests/brain/numpy/test_core_umath.py::NumpyBrainCoreUmathTest::test_numpy_core_umath_functions_return_type_tuple - AssertionError: False is not true : Illicit type for frexp (Uninferable)
FAILED tests/test_regrtest.py::NonRegressionTests::test_numpy_distutils - AssertionError: Uninferable is not an instance of <class 'astroid.nodes.node_classes.Const'>
================================= 8 failed, 1649 passed, 14 skipped, 16 xfailed, 1 xpassed in 37.53s ==================================
Expected behavior
Tests passing :-).
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output
3.3.0-dev0
(I've reproduced with e43e045)