Skip to content

Fix Python workflow not running specified version#453

Open
AndrewADev wants to merge 4 commits intoJij-Inc:mainfrom
AndrewADev:fix/run-specified-python-version-in-workflow
Open

Fix Python workflow not running specified version#453
AndrewADev wants to merge 4 commits intoJij-Inc:mainfrom
AndrewADev:fix/run-specified-python-version-in-workflow

Conversation

@AndrewADev
Copy link
Copy Markdown
Contributor

@AndrewADev AndrewADev commented Apr 25, 2026

Summary

Fix an issue where the Python workflow was not running the specified Python version due to it not being accepted by the version of setup-uv that was previously in use (trying to update just a couple actions is what lead me here).

Then migrate away from uv workspaces for the examples, since uv will only ever resolve a single version of python, which causes conflicts with the requires-python specifier of "3.12" listed in the type-statement-alias example (it fails to find an interpreter in the 3.10, 3.11 run contexts). Also add new tasks to cover adding and bumping packages to compensate for the drudgery of not having workspaces.

Lastly, follow-up on any breakages that resulted from fresh resolution of packages and updated versions.

Background

Currently, the main Python test workflow is not running the version of Python specified in the matrix.

This can be seen when looking at the logs. Here, for instance, using 3.12 when the matrix combination intends to target 3.10:

image

Or when it is supposed to be using 3.13:

image

Support for specifying python-version in the setup-uv action wasn't added until v4.1.0, so the place where the python version is passed is ignored.

This also shows up as warning in the summary, since it is using an unexpected input for v3 of the action:

image

Unfortunately, simply upgrading leads to a failure, as uv resolves the intersection of various requires-python versions:

image

Finally, uv's workspaces enforce a single requires-python for the entire workspace, taking the intersection of all members' requires-python values.

From the uv workspaces documentation

Which then leads to issues with the tests for python < 3.12, since uv can no longer satisfy the combined requirements.

In light of this, the changes in this PR propose moving away from workspaces for the examples, maintaining uv for package management, but with example-specific uv.lock files (and thus more isolated contexts).

Fix an issue where the Python workflow was not running the specified Python version due to it not being accepted by the version of setup-uv that was previously in use.

Then migrate away from uv workspaces for the examples, since they will only ever resolve a single version of python, which causes conflicts with the requires-python specifier of "3.12" listed in the type-statement-alias example (can't find an interpreter in the 3.10, 3.11 run contexts).

Lastly, add new tasks to cover adding and bumping packages to compensate for the drudgery of not having workspaces.
Fix a syrupy test for newer API and generate snapshot file in new format.
Fix an issue where an unused extension, which was not listed as a dependency, was crashing a doc-test, since the package couldn't be found.
The cache created by uv is never written to for rust-only workflows, which was leading to a crash when the cleanup step tried removing a non-existent directory.
@AndrewADev AndrewADev force-pushed the fix/run-specified-python-version-in-workflow branch from d63f5bb to ef0e25c Compare April 25, 2026 09:42
@AndrewADev
Copy link
Copy Markdown
Contributor Author

AndrewADev commented Apr 25, 2026

RE: pending checks - these won't run by definition, since they aren't compatible with the requires-python= ">=3.12" specifier in the type-statement-alias example:

Screenshot 2026-04-25 at 11 53 59

The cleanest solution would be to exclude them from the required checks, if that is possible (looking at the rulesets with gh api repos/Jij-Inc/pyo3-stub-gen/rulesets/267479 makes it look like there are explicitly mentioned there, so this is hopefully the case)

[dependency-groups]
dev = ["myst-parser", "sphinx", "sphinx-rtd-theme"]
dev = [
"mypy==1.19.1",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is to avoid pulling in changes to the main stub generation code as part of this PR.

The fix for the issue with newer versions of mypy (1.20+) is available in a separate PR: #452

description: "Python version to install"
required: false
default: "3.10"
enable-uv-cache:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixes this:
Image

@AndrewADev AndrewADev marked this pull request as ready for review April 25, 2026 09:53
Comment on lines -19 to -23
"sphinxcontrib.katex",
]

myst_enable_extensions = [
"dollarmath",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixes this

Image

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.

1 participant