Current Behavior
In my project, I have a .python-version file to pin a version for development and CI:
and noxfile.py:
from __future__ import annotations
import nox
nox.options.default_venv_backend = "uv"
@nox.session(requires=["uv"])
@nox.parametrize(
"python",
[
"3.10",
"3.11",
"3.12",
"3.13",
"3.14",
],
)
def pytest(session: nox.Session) -> None:
session.run_install(
"uv",
"sync",
"--no-dev",
"--group=pytest",
"--frozen",
env={
"UV_PROJECT_ENVIRONMENT": session.virtualenv.location,
},
)
session.run("pytest")
I noticed that Nox creates the environments based on Python 3.14 only. If I remove the .python-version file, everything works as expected, i.e. the respective Python versions are installed and tested.
Expected Behavior
Nox should not care about the .python-version file and enforce the Python version specified by the session's parameter.
Steps To Reproduce
- Run
nox with .python-version (with 3.14 for a reference).
- Check
.nox/ contents — Python 3.14 is found in each environment.
rm -rf .nox/.
rm .python-version.
- Run
nox again.
- Check
.nox/ contents — now the Python versions are as expected.
Environment
Anything else?
A workaround:
@nox.session(requires=["uv"])
@nox.parametrize(
"python",
[
"3.10",
"3.11",
"3.12",
"3.13",
"3.14",
],
)
def pytest(session: nox.Session, python: str) -> None: # 'python' as explicit parameter
session.run_install(
"uv",
"sync",
f"--python={python}", # the proper version installed via uv
"--no-dev",
"--group=pytest",
"--frozen",
env={
"UV_PROJECT_ENVIRONMENT": session.virtualenv.location,
},
)
session.run("pytest")
Current Behavior
In my project, I have a
.python-versionfile to pin a version for development and CI:and
noxfile.py:I noticed that Nox creates the environments based on Python 3.14 only. If I remove the
.python-versionfile, everything works as expected, i.e. the respective Python versions are installed and tested.Expected Behavior
Nox should not care about the
.python-versionfile and enforce the Python version specified by the session's parameter.Steps To Reproduce
noxwith.python-version(with3.14for a reference)..nox/contents — Python 3.14 is found in each environment.rm -rf .nox/.rm .python-version.noxagain..nox/contents — now the Python versions are as expected.Environment
Anything else?
A workaround: