Skip to content

Conversation

@ramanbansal1
Copy link

@ramanbansal1 ramanbansal1 commented Dec 25, 2025

In #3619 and #3624, CI pre-commit checks were observed to flag different issues than local runs due to implicit Python and dependency resolution. This change removes that under-determination by:

  • Explicitly pinning the Python version used by pre-commit hooks (3.11)
    Fixes pre-commit is under-determined #3624
    This ensures consistent behavior between local development and CI, reducing contributor friction.

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Dec 25, 2025
@d-v-b
Copy link
Contributor

d-v-b commented Dec 25, 2025

@ramanbansal1 thanks for this! One thing I am wondering -- could we achieve the same outcome, but in a more generic way, by adding a .python-version file to the repo?

@ramanbansal1
Copy link
Author

Thanks for the suggestion — a .python-version file is definitely useful, and I agree it would be good to have a single, visible declaration of the project’s preferred Python version.

However, pre-commit itself does not consume .python-version (or any other project files) when selecting the interpreter for hooks. It only uses what is explicitly declared in .pre-commit-config.yaml via default_language_version / language_version. As a result, adding .python-version alone would not make pre-commit deterministic, and we would still see CI vs local mismatches depending on which Python pre-commit discovers.

@ramanbansal1
Copy link
Author

However i can create a hook that will check versions and if not found will change it .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs release notes Automatically applied to PRs which haven't added release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pre-commit is under-determined

2 participants