ci: test Ops 2.23 with Python 3.14#2576
Conversation
tonyandrewmeyer
left a comment
There was a problem hiding this comment.
If we do this, we should do a follow-up PR to adjust the tools/versions page. I left off 26.04 support for 2.23 there specifically because we weren't doing this testing.
I'm not sure if we want to always do this (3.16 in 28.04, 3.18 in 30.04, and so on), because we'd rather that people have new branches for newer bases and move to 3.x, but then maybe being LTS means that we ought to. As long as it's almost no work, I guess it doesn't hurt.
(Submitting this now because I'd already written it, even though you just said leave this until it's out of draft.)
functools.partial became a descriptor in Python 3.14 (gh-131111), so when stored as a class attribute and accessed via an instance it binds \`self\` as the first positional argument. This corrupted the json.loads/json.dumps call signature in the relation data class tests, producing errors like: TypeError: loads() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given Wrap the partial-based encoder/decoder class attributes in staticmethod() to preserve the pre-3.14 behaviour, matching the resolution on main. Cherry-pick of the test-file portion of canonical#2091 (commit 2ef02b6). Upstream PR: canonical#2091
…tials The staticmethod() wrappers added in the previous commit are not recognised by the pinned pyright 1.1.385 as assignable to the \`Callable | None\` annotations on BaseTestCharm.encoder/decoder (newer pyright versions handle this correctly, as on main). Add targeted \`# type: ignore[reportAssignmentType]\` comments so the static check passes with the pinned version.
|
Thanks for the comment, Tony. I don't have strong feelings about whether we want to support Python 3.14 on Ops 2.23. We don't require any code changes to support it, this PR is just enabling testing on Python 3.14. But maybe it's fair for us to say our LTS support is limited to specific Python versions. |
tonyandrewmeyer
left a comment
There was a problem hiding this comment.
Nice, thanks for doing this. I think we maybe should have a discussion about whether 3.14 (or really 26.04) is support for 2.23, but we can do that later.
5698b3f
into
canonical:2.23-maintenance
#2546 is blocked because we don't run the tests on this branch with Python 3.14, but these are configured as required checks. Since Ops 2.23 only specifies Python
>=3.8, we'd expect it to run fine with Python 3.14.In addition to adding 3.14 to the list of versions in CI, we also need to add it to the list of environments in
tox.ini, and follow #2091 in patching some of the tests: we now need to wrap ourfunctools.partialobjects instaticmethoddue topartialimplementing the decriptor protocol in Python 3.14 (python/cpython#121027, python/cpython#121089). However, because we're on an olderpyrightversion in this maintenance branch, this leads to type checking errors which we ignore (bumpingpyrightresolves this but introduces 20+ other errors which would add noise to this PR).