python-tox fails to build with Python 3.14.0a6. _ test_str_convert_nok[3-Union-TypeError-3 cannot cast to typing.Union\\[str, int\\]] _ [gw0] linux -- Python 3.14.0 /usr/bin/python3 raw = '3', of_type = str | int msg = '3 cannot cast to typing.Union\\[str, int\\]' exc_type = <class 'TypeError'> @pytest.mark.parametrize( ("raw", "of_type", "exc_type", "msg"), [ ("a", TypeVar, TypeError, r"a cannot cast to .*typing.TypeVar.*"), ("3", Literal["1", "2"], ValueError, r"3 must be one of \('1', '2'\)"), ("3", Union[str, int], TypeError, r"3 cannot cast to typing.Union\[str, int\]"), ("", Command, ValueError, r"attempting to parse '' into a command failed"), ], ) def test_str_convert_nok(raw: str, of_type: type[Any], msg: str, exc_type: type[Exception]) -> None: with pytest.raises(exc_type, match=msg): > StrConvert().to(raw, of_type, None) exc_type = <class 'TypeError'> msg = '3 cannot cast to typing.Union\\[str, int\\]' of_type = str | int raw = '3' tests/config/loader/test_str_convert.py:86: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.14/site-packages/tox/config/loader/convert.py:33: in to return self._to_typing(raw, of_type, factory) factory = None from_module = 'typing' of_type = str | int raw = '3' self = <tox.config.loader.str_convert.StrConvert object at 0x7f2515eb1a90> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <tox.config.loader.str_convert.StrConvert object at 0x7f2515eb1a90> raw = '3', of_type = str | int, factory = None def _to_typing(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: C901 origin = getattr(of_type, "__origin__", of_type.__class__) result: Any = _NO_MAPPING if origin in {list, List}: entry_type = of_type.__args__[0] # type: ignore[attr-defined] result = [self.to(i, entry_type, factory) for i in self.to_list(raw, entry_type)] if isclass(entry_type) and issubclass(entry_type, Command): result = [i for i in result if i is not None] elif origin in {set, Set}: entry_type = of_type.__args__[0] # type: ignore[attr-defined] result = {self.to(i, entry_type, factory) for i in self.to_set(raw, entry_type)} elif origin in {dict, Dict}: key_type, value_type = of_type.__args__[0], of_type.__args__[1] # type: ignore[attr-defined] result = OrderedDict( (self.to(k, key_type, factory), self.to(v, value_type, factory)) for k, v in self.to_dict(raw, (key_type, value_type)) ) elif origin == Union: # handle Optional values args: list[type[Any]] = of_type.__args__ # type: ignore[attr-defined] none = type(None) if len(args) == 2 and none in args: # noqa: PLR2004 if isinstance(raw, str): raw = raw.strip() # type: ignore[assignment] if not raw: result = None else: new_type = next(i for i in args if i != none) # pragma: no cover result = self.to(raw, new_type, factory) elif origin in {Literal, type(Literal)}: choice = of_type.__args__ # type: ignore[attr-defined] if raw not in choice: msg = f"{raw} must be one of {choice}" raise ValueError(msg) result = raw if result is not _NO_MAPPING: return cast("V", result) msg = f"{raw} cannot cast to {of_type!r}" > raise TypeError(msg) E TypeError: 3 cannot cast to str | int args = (<class 'str'>, <class 'int'>) factory = None msg = '3 cannot cast to str | int' none = <class 'NoneType'> of_type = str | int origin = <class 'typing.Union'> raw = '3' result = <object object at 0x7f251d779830> self = <tox.config.loader.str_convert.StrConvert object at 0x7f2515eb1a90> ../BUILDROOT/usr/lib/python3.14/site-packages/tox/config/loader/convert.py:92: TypeError During handling of the above exception, another exception occurred: raw = '3', of_type = str | int msg = '3 cannot cast to typing.Union\\[str, int\\]' exc_type = <class 'TypeError'> @pytest.mark.parametrize( ("raw", "of_type", "exc_type", "msg"), [ ("a", TypeVar, TypeError, r"a cannot cast to .*typing.TypeVar.*"), ("3", Literal["1", "2"], ValueError, r"3 must be one of \('1', '2'\)"), ("3", Union[str, int], TypeError, r"3 cannot cast to typing.Union\[str, int\]"), ("", Command, ValueError, r"attempting to parse '' into a command failed"), ], ) def test_str_convert_nok(raw: str, of_type: type[Any], msg: str, exc_type: type[Exception]) -> None: > with pytest.raises(exc_type, match=msg): E AssertionError: Regex pattern did not match. E Regex: '3 cannot cast to typing.Union\\[str, int\\]' E Input: '3 cannot cast to str | int' exc_type = <class 'TypeError'> msg = '3 cannot cast to typing.Union\\[str, int\\]' of_type = str | int raw = '3' https://docs.python.org/3.14/whatsnew/3.14.html For the build logs, see: https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08783548-python-tox/ For all our attempts to build python-tox with Python 3.14, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-tox/ 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.14: https://copr.fedorainfracloud.org/coprs/g/python/python3.14/ Let us know here if you have any questions. Python 3.14 is planned to be included in Fedora 43. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14. 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.
Fix proposed upstream in https://github.com/tox-dev/tox/pull/3500
https://src.fedoraproject.org/rpms/python-tox/pull-request/173
FEDORA-2025-d2222deddf (python-tox-4.25.0-2.fc43) has been submitted as an update to Fedora 43. https://bodhi.fedoraproject.org/updates/FEDORA-2025-d2222deddf
FEDORA-2025-d2222deddf (python-tox-4.25.0-2.fc43) has been pushed to the Fedora 43 stable repository. If problem still persists, please make note of it in this bug report.