Skip to content

Add base_python_file config option#3899

Merged
gaborbernat merged 12 commits intotox-dev:mainfrom
rahuldevikar:feature/base-python-file-3894
Mar 27, 2026
Merged

Add base_python_file config option#3899
gaborbernat merged 12 commits intotox-dev:mainfrom
rahuldevikar:feature/base-python-file-3894

Conversation

@rahuldevikar
Copy link
Copy Markdown
Collaborator

@rahuldevikar rahuldevikar commented Mar 25, 2026

Adds a new base_python_file configuration option that reads the base Python version from a file (e.g. .python-version), similar to GitHub Actions' python-version-file.

Fixes #3894

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

@rahuldevikar rahuldevikar force-pushed the feature/base-python-file-3894 branch 2 times, most recently from dc1c3a5 to e987d7a Compare March 25, 2026 16:52
@rahuldevikar rahuldevikar force-pushed the feature/base-python-file-3894 branch from d77feae to 3193585 Compare March 25, 2026 16:58
@rahuldevikar rahuldevikar marked this pull request as ready for review March 25, 2026 22:53
.. conf::
:keys: base_python_file
:default: <empty string>
:version_added: 4.x
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fix the version here

.. code-block:: toml

[env.mypy]
base_python_file = ".python-version"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

base_python_file should be a list of file and pick first available, essentialy mirroring base_python

our.add_argument("--strict", action="store_true", help="Disallow extra properties in configuration")


def _ensure_package_conf(env: ToxEnv) -> None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

methods shoulkd be defiend afgter they are used not before

The schema must include *all* possible configuration keys regardless of the current project settings.

"""
from tox.tox_env.python.runner import PythonRun # noqa: PLC0415
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should avoid local imports

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I meant why do we need to do a local import and a patching private fields.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I see, I removed the method in the new iteration. lmk.

@gaborbernat gaborbernat marked this pull request as draft March 26, 2026 05:30
@rahuldevikar rahuldevikar marked this pull request as ready for review March 26, 2026 18:27
@gaborbernat gaborbernat merged commit 106f036 into tox-dev:main Mar 27, 2026
27 checks passed
gaborbernat pushed a commit to gaborbernat/tox that referenced this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for version files

2 participants