-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Python 3.14 support #5352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I tested Python 3.14 alpha 5 and all type conversion related tests succeeded. I don't know the exact status of PEP 649, but at least the current changes don't seem to affect us. |
The only tests that failed were using the jsonschema module for validating JSON outputs by Libdoc and Robot. The reason is that this module doesn't have Python 3.14 compatible releases available and compiling the Rust code it uses failed: We needed to wait for Python 3.13 compatible jsonschema version for quite a long time as well. At the moment missing jsonschema module cases problems also with unrelated tests, but I (party) fixed that locally and was able to run tests. I probably should fix this issue properly and also allow excluding tests needing jsonschema with |
- Acceptance test libraries gracefully handle the module not being available. Schema validation will obviously fail, but otherwise libraries work normally. - Acceptance tests needing jsonschema got a new `require-jsonschema` tag that can be used for skipping or excluding them. - Unit tests needing jsonschema are skipped if the module isn't installed. The motivation with these changes is making it possible to test Robot on Python 3.14 that isn't currently supported by jsonschema. (#5352)
Attaching to this for Fedora 43 we are testing with Python 3.14 and with a6 I see some tests failing and are all around Unions. I see from the changelogs of Python that stuff was indeed changed around unions, but my understanding of the details is sadly not right now good enough to be of concrete help. Output of failed tests:
I did a few tests by hand on the shell around what tests execute that could hopefully give some more inputs for you:
If I can be of any help testing or trying something please just let me know! |
Thanks for the info! I need to test with a6 myself. Is it easy to get Python preview releases installed on Fedora? I'm currently using Mint/Ubuntu with DeadSnakes, but could install Fedora to a virtual machine to test it out. I need a new laptop soon and although I've been happy with Mint, it would be interesting to look for alternatives. |
There is a very active team testing Python upcoming versions and what is nice is that you can test those using the "mock" tool which basically creates a chroot with a set of packages (in this case Python preview but could be anything) where you can easily experiment without really installing on your system (and possibly messing up ;) ). In this case then you tell mock to use their previews packages and you get the environment immediately. (just to give a reference, here: https://copr.fedorainfracloud.org/coprs/g/python/python3.14/ ) So I'd say: yeah it is pretty easy and comfortable to generate roots with different versions (or combinations of) with their standard tooling! (I don't know Mint/Ubuntu + DeadSnakes tho to be able to compare if it would be easier or not) |
I was able to reproduce the problem. I explain why it occurs and how it can be fixed below. Previously the >>> from typing import Union
>>> Union.__args__
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
Union.__args__
File "/usr/lib/python3.13/typing.py", line 548, in __getattr__
raise AttributeError(item)
AttributeError: __args__. Did you mean: '__ror__'?
>>> Union.__origin__
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
Union.__origin__
File "/usr/lib/python3.13/typing.py", line 548, in __getattr__
raise AttributeError(item)
AttributeError: __origin__
>>> Now in Python 3.14 alpha 6 they exist but aren't really usable: >>> from typing import Union
>>> Union.__args__
<member '__args__' of 'typing.Union' objects>
>>> list(Union.__args__)
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
list(Union.__args__)
~~~~^^^^^^^^^^^^^^^^
TypeError: 'member_descriptor' object is not iterable
>>> Union.__origin__
<attribute '__origin__' of 'typing.Union' objects>
>>> type(Union.__origin__)
<class 'getset_descriptor'> The problem can be avoided by using >>> from typing import get_args, get_origin, Union
>>> get_args(Union)
()
>>> get_origin(Union) is None
True I guess the reason we haven't consistently used It's somewhat strange that >>> from types import UnionType
>>> from typing import Union
>>> UnionType is Union
True In earlier versions >>> from types import UnionType
>>> UnionType.__args__
<member '__args__' of 'types.UnionType' objects>
>>> list(UnionType.__args__)
Traceback (most recent call last):
File "<python-input-7>", line 1, in <module>
list(UnionType.__args__)
~~~~^^^^^^^^^^^^^^^^^^^^
TypeError: 'member_descriptor' object is not iterable
>>> UnionType.__origin__
Traceback (most recent call last):
File "<python-input-8>", line 1, in <module>
UnionType.__origin__
AttributeError: type object 'types.UnionType' has no attribute '__origin__' I'm not sure could |
Using `typing.get_args(x)` and `typing.get_origin(x)` is simpler than using `getattr(x, '__args__', None)` and `getattr(x, '__origin__', None)`. It also avoids problems in some corner cases. Most mportantly, it avoids issues with `Union` containing unusable `__args__` and `__origin__` in Python 3.14 alpha 6 (#5352). `get_args` (new in Python 3.8) also makes our `has_args` redundant and it is deprecated.
Thanks a lot for the immediate action! I can confirm also on my side that applying your patch solves the issue! I will report to the Fedora Python team about the Union change as I think they have more contacts with Python team. As we get newer preview versions in Fedora will keep rebuilding there and let you know if I spot anything else! |
Sounds good. Although the |
See PEP 649 for details. Part of Python 3.14 support (#5352).
I moved this issue from RF 7.3 scope to RF 7.4. The reason is that we are going to released the former in April, and I don't think we can declare official Python 3.14 support until it is in beta and all features are in. RF 7.3, and also earlier versions, is compatible with the current Python 3.14 alphas, though. |
Python 3.14 will be released in October 2025, but we should make sure Robot Framework is compatible with it already now.
Probably the biggest change in Python 3.14, and certainly the change that can affect Robot Framework the most, is deferred evaluation of annotations (PEP 649). Robot uses annotations for type conversion and such runtime annotation usage isn't that typical.
The text was updated successfully, but these errors were encountered: