python-astroid fails to build with Python 3.13.0a2. =================================== FAILURES =================================== ___________ test_dataclasses_subscript_inference_recursion_error_39 ____________ @pytest.mark.skipif( not PY39_PLUS, reason="Exact inference with dataclasses (replace function) in python3.9", ) def test_dataclasses_subscript_inference_recursion_error_39(): 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) infer_val = util.safe_infer(node) > assert isinstance(infer_val, Instance) E assert False E + where False = isinstance(Uninferable, Instance) tests/test_inference.py:6731: AssertionError _______________ TypingBrain.test_typing_annotated_subscriptable ________________ self = <tests.brain.test_brain.TypingBrain testMethod=test_typing_annotated_subscriptable> @test_utils.require_version(minver="3.9") def test_typing_annotated_subscriptable(self): """Test typing.Annotated is subscriptable with __class_getitem__""" node = builder.extract_node( """ import typing typing.Annotated[str, "data"] """ ) inferred = next(node.infer()) assert isinstance(inferred, nodes.ClassDef) > assert isinstance(inferred.getattr("__class_getitem__")[0], nodes.FunctionDef) tests/brain/test_brain.py:641: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <ClassDef.Annotated l.10 at 0x7faefc93e120>, name = '__class_getitem__' context = None, class_context = True def getattr( self, name: str, context: InferenceContext | None = None, class_context: bool = True, ) -> list[InferenceResult]: """Get an attribute from this class, using Python's attribute semantic. This method doesn't look in the :attr:`instance_attrs` dictionary since it is done by an :class:`Instance` proxy at inference time. It may return an :class:`Uninferable` object if the attribute has not been found, but a ``__getattr__`` or ``__getattribute__`` method is defined. If ``class_context`` is given, then it is considered that the attribute is accessed from a class context, e.g. ClassDef.attribute, otherwise it might have been accessed from an instance as well. If ``class_context`` is used in that case, then a lookup in the implicit metaclass and the explicit metaclass will be done. :param name: The attribute to look for. :param class_context: Whether the attribute can be accessed statically. :returns: The attribute. :raises AttributeInferenceError: If the attribute cannot be inferred. """ if not name: raise AttributeInferenceError(target=self, attribute=name, context=context) # don't modify the list in self.locals! values: list[InferenceResult] = list(self.locals.get(name, [])) for classnode in self.ancestors(recurs=True, context=context): values += classnode.locals.get(name, []) if name in self.special_attributes and class_context and not values: result = [self.special_attributes.lookup(name)] if name == "__bases__": # Need special treatment, since they are mutable # and we need to return all the values. result += values return result if class_context: values += self._metaclass_lookup_attribute(name, context) # Remove AnnAssigns without value, which are not attributes in the purest sense. for value in values.copy(): if isinstance(value, node_classes.AssignName): stmt = value.statement() if isinstance(stmt, node_classes.AnnAssign) and stmt.value is None: values.pop(values.index(value)) if not values: > raise AttributeInferenceError(target=self, attribute=name, context=context) E astroid.exceptions.AttributeInferenceError: '__class_getitem__' not found on <ClassDef.Annotated l.10 at 0x7faefc93e120>. astroid/nodes/scoped_nodes/scoped_nodes.py:2425: AttributeInferenceError =========================== short test summary info ============================ FAILED tests/test_inference.py::test_dataclasses_subscript_inference_recursion_error_39 FAILED tests/brain/test_brain.py::TypingBrain::test_typing_annotated_subscriptable =========== 2 failed, 1581 passed, 77 skipped, 16 xfailed in 18.03s ============ https://docs.python.org/3.13/whatsnew/3.13.html For the build logs, see: https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06750187-python-astroid/ For all our attempts to build python-astroid with Python 3.13, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-astroid/ Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.13: https://copr.fedorainfracloud.org/coprs/g/python/python3.13/ Let us know here if you have any questions. Python 3.13 is planned to be included in Fedora 41. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13. A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon. We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.
This bug appears to have been reported against 'rawhide' during the Fedora Linux 40 development cycle. Changing version to 40.
Two more tests fail with Python 3.13.0a5: FAILED tests/brain/test_pathlib.py::test_inference_parents - AssertionError: ... FAILED tests/brain/test_pathlib.py::test_inference_parents_subscript_index - ...