Open mgorny opened 5 months ago
Thank you for opening the issue. We also had issue with the numpy's brain when trying to analyses the pyi in #2375, we have to check if our brain where still up to date with latest numpy and if analysing pyi was a better bet. With some knowledge gathered with pylint 3.2.0 's release it seems the pyi are not ready (we have to merge pyi with the implementation because using the pyi and having an empty function body doesn't work). We never had to make brain for 2 versions of a lib before so either way, there's probably prior work to do to make this work.
Numpy 2.1 came with a bunch of typing-related fixes. So it might be worth checking whether these tests still fail against it.
Steps to reproduce
tox -e py312
. .tox/py312/bin/activate
pip install numpy==2.0.0rc2
pytest
Current behavior
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 =Expected behavior
Tests passing :-).
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output3.3.0-dev0
(I've reproduced with e43e045179fe4df7ba2aed96ad5ef180232f39cc)