Skip to content

Add Python 3.14 support#206

Merged
rtibbles merged 1 commit intolearningequality:mainfrom
rtibblesbot:issue-205-3bc71a
Mar 18, 2026
Merged

Add Python 3.14 support#206
rtibbles merged 1 commit intolearningequality:mainfrom
rtibblesbot:issue-205-3bc71a

Conversation

@rtibblesbot
Copy link
Contributor

@rtibblesbot rtibblesbot commented Mar 17, 2026

Summary

Upgrades pytest from ==6.2.5 to >=6.2.5,<8 so tests pass on Python 3.14 (the pinned version used removed ast node types). Updates python_requires, tox, and CI matrix to include Python 3.14.

References

Reviewer guidance

  • The pytest version range >=6.2.5,<8 keeps compatibility with the existing test suite while picking up Python 3.14 support from pytest 7.2+
  • No monkey patching needed — upgrading the test dependency is sufficient since it's not a production dependency

AI usage

Claude Code implemented the changes. All generated code was reviewed for correctness and tested against the full test suite.


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks

@rtibblesbot rtibblesbot marked this pull request as ready for review March 17, 2026 22:25
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Concerned you might be overcomplicating this - did you try a simpler way forward?

@@ -0,0 +1,105 @@
"""Tests for the ast compatibility monkey patch in conftest.py."""
Copy link
Member

Choose a reason for hiding this comment

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

This feels like overkill - either the ast monkey patch fixes the tests in Python 3.14 or it doesn't - that's the test of whether it works or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed — removed the dedicated test file in a2ce302. The existing test suite already validates whether the monkey patch works.

conftest.py Outdated
@@ -0,0 +1,68 @@
# Monkey patch to restore deprecated ast node types removed in Python 3.14.
Copy link
Member

Choose a reason for hiding this comment

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

Could we not just use pytest>=6.2.5,<8 in the test requirements to avoid all this extra work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The acceptance criteria on the issue specifies: "Conflicting dependency versions should be fixed by way of monkey patching. Do not use Python-version-specific dependency ranges." That's why this uses a monkey patch rather than updating the pytest version constraint.

Copy link
Member

Choose a reason for hiding this comment

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

That's only a concern for production dependencies, the wording is imprecise. This is a test only dependency, and as long as the pytest API is sufficiently similar between version 6 and 7 this is a very minor concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right — the constraint in the acceptance criteria is about production dependencies, not test-only ones. Replaced the monkey patch with pytest>=6.2.5,<8 in requirements-test.txt and squashed to a single commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed — pytest is test-only, so the version-range constraint doesn't apply here. Replaced the monkey patch with pytest>=6.2.5,<8 in requirements-test.txt and squashed to a single commit. All 64 tests pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed — pytest is test-only, so the version-range constraint doesn't apply here. Replaced the monkey patch with pytest>=6.2.5,<8 in requirements-test.txt and squashed to a single commit. All 64 tests pass.

conftest.py Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the overcomplexity concern: removed the dedicated test file (the existing suite is sufficient validation). The monkey-patch approach itself is required by the issue's acceptance criteria — it mandates fixing via monkey patching rather than changing dependency versions.

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

I think the acceptance criteria are imprecise. Make this change, then squash the commit history to one commit.

conftest.py Outdated
@@ -0,0 +1,68 @@
# Monkey patch to restore deprecated ast node types removed in Python 3.14.
Copy link
Member

Choose a reason for hiding this comment

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

That's only a concern for production dependencies, the wording is imprecise. This is a test only dependency, and as long as the pytest API is sufficiently similar between version 6 and 7 this is a very minor concern.

Upgrade pytest from ==6.2.5 to >=6.2.5,<8 to resolve ast module
incompatibilities on Python 3.14. Update python_requires upper bound,
tox environments, and GitHub Actions test matrix to include Python 3.14.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rtibbles rtibbles changed the title Add Python 3.14 support via ast monkey patch Add Python 3.14 support Mar 18, 2026
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Simply done!

@rtibbles rtibbles merged commit 0fb6085 into learningequality:main Mar 18, 2026
18 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.

Python 3.14 Support

2 participants