Skip to content

ci: test Ops 2.23 with Python 3.14#2576

Merged
james-garner-canonical merged 4 commits into
canonical:2.23-maintenancefrom
james-garner-canonical:26-06+ci+run-2-23-maintenance-unit-tests-on-py-3-14
Jun 23, 2026
Merged

ci: test Ops 2.23 with Python 3.14#2576
james-garner-canonical merged 4 commits into
canonical:2.23-maintenancefrom
james-garner-canonical:26-06+ci+run-2-23-maintenance-unit-tests-on-py-3-14

Conversation

@james-garner-canonical

@james-garner-canonical james-garner-canonical commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

#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.

image

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 our functools.partial objects in staticmethod due to partial implementing the decriptor protocol in Python 3.14 (python/cpython#121027, python/cpython#121089). However, because we're on an older pyright version in this maintenance branch, this leads to type checking errors which we ignore (bumping pyright resolves this but introduces 20+ other errors which would add noise to this PR).

@tonyandrewmeyer tonyandrewmeyer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@james-garner-canonical james-garner-canonical marked this pull request as ready for review June 22, 2026 03:14
@james-garner-canonical

Copy link
Copy Markdown
Contributor Author

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 tonyandrewmeyer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dwilding dwilding left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@james-garner-canonical james-garner-canonical merged commit 5698b3f into canonical:2.23-maintenance Jun 23, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants