Skip to content

Update pre-commit default language version#2185

Closed
pankajastro wants to merge 1 commit into
mainfrom
update_pre_commit_default_language_version
Closed

Update pre-commit default language version#2185
pankajastro wants to merge 1 commit into
mainfrom
update_pre_commit_default_language_version

Conversation

@pankajastro
Copy link
Copy Markdown
Contributor

@pankajastro pankajastro commented Dec 5, 2025

I'm using Python 3.11 virtual environment and getting below error

[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/pankaj/Documents/astro_code/astronomer-cosmos/devenv/bin/python3.11', '-mvirtualenv', '/Users/pankaj/.cache/pre-commit/repou5hulpgs/py_env-python3.10', '-p', 'python3.10')
return code: 1
stdout:
    RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.10'
stderr: (none)
Check the log at /Users/pankaj/.cache/pre-commit/pre-commit.log

Changed default_language_version.python from python3.10 to python3 to allow pre-commit to use any available Python 3 interpreter

@pankajastro pankajastro marked this pull request as ready for review December 5, 2025 06:26
Copilot AI review requested due to automatic review settings December 5, 2025 06:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the pre-commit configuration to use a generic python3 version instead of the hardcoded python3.10, resolving an error for developers using Python 3.11 or other supported versions.

Key Changes:

  • Changed default_language_version.python from python3.10 to python3 to allow pre-commit to use any available Python 3 interpreter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (768513d) to head (4cdb139).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2185   +/-   ##
=======================================
  Coverage   97.84%   97.84%           
=======================================
  Files          94       94           
  Lines        6038     6038           
=======================================
  Hits         5908     5908           
  Misses        130      130           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread .pre-commit-config.yaml
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.10
python: python3
Copy link
Copy Markdown
Collaborator

@tatiana tatiana Dec 5, 2025

Choose a reason for hiding this comment

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

This fails if the person has Python 3.9 installed their local environment. We can pin to another version

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.

Python 3.9 has reached EOL, and we decided to drop support for Python 3.9

Copy link
Copy Markdown
Contributor Author

@pankajastro pankajastro Dec 5, 2025

Choose a reason for hiding this comment

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

I have a Python 3.11 virtual environment, and I'm hitting an issue. I try to follow the Airflow setting https://github.com/apache/airflow/blob/main/.pre-commit-config.yaml, but please let me know if you want me to test for some other version

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@pankajastro I fully understand, but developers may still have Python 3.9 installed in their local environment, and - this happened to me - unless we tell pre-commit, it may get the incorrect version of Python, which will conflict with pre-commit hooks that do not support that version.
It would be great if we set the minimum acceptable version, or at least the same version that the CI uses. I'm happy for that to be Python 3.11.
To set just Python 3 is not sufficient, I'm afraid

Copy link
Copy Markdown
Contributor Author

@pankajastro pankajastro Dec 8, 2025

Choose a reason for hiding this comment

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

developers may still have Python 3.9 installed in their local environment

I think they should move to Python 3.10 or newer, given pre-commit needs Python 3.10 or newer https://github.com/pre-commit/pre-commit/blob/main/setup.cfg#L26

It would be great if we set the minimum acceptable version

I checked the docs but could not find a way to set the Python min version. Maybe if we want, we can have a local pre-commit

at least the same version that the CI uses

Which CI job are you referring to? I think we run with multiple Python versions, except fews jobs

I'm happy for that to be Python 3.11.

If we set the default to Python 3.11, then it may cause issues for the contributor having Python version 3.10, or 3.12

Please do let me know how we should handle this.

@tatiana tatiana changed the title Update pre-commit default langauge version Update pre-commit default language version Dec 5, 2025
@pankajastro pankajastro force-pushed the update_pre_commit_default_language_version branch from 3cda897 to 4cdb139 Compare December 8, 2025 14:37
@pankajastro pankajastro requested a review from tatiana December 9, 2025 07:54
@tatiana
Copy link
Copy Markdown
Collaborator

tatiana commented Dec 9, 2025

Closing this since the issue was solved in #2190

@tatiana tatiana closed this Dec 9, 2025
@pankajastro
Copy link
Copy Markdown
Contributor Author

Closing this since the issue was solved in #2190

I'm not sure how #2190 resolves this—could you clarify?

@pankajkoti
Copy link
Copy Markdown
Contributor

@pankajastro @tatiana -- I am not sure if this PR could solve the issue, or if we need another fix. But my local commits with branches cut from the latest main are failing and I have Python 3.12 installed on my local. For now, I am pushing the commits with --no-verify and relying on the CI pre-commit bot to take care of pre-commit fixes for me in the PRs opened.

@pankajastro
Copy link
Copy Markdown
Contributor Author

@pankajastro @tatiana -- I am not sure if this PR could solve the issue, or if we need another fix. But my local commits with branches cut from the latest main are failing and I have Python 3.12 installed on my local. For now, I am pushing the commits with --no-verify and relying on the CI pre-commit bot to take care of pre-commit fixes for me in the PRs opened.

@pankajkoti I tested this PR locally using a Python 3.11 virtual environment, and it worked. I'm also using --no-verify for now

@tatiana
Copy link
Copy Markdown
Collaborator

tatiana commented Dec 12, 2025

tatiana added a commit that referenced this pull request Dec 12, 2025
I incorrectly closed #2185, thinking that the `- --py310-plus` syntax
used in #2190 was `pre-commit`, not pyupgrade specific.

This PR aims to allow anyone using `Python versions => 3.10` to be able
to run `pre-commit`, while failing if a previous version is used.
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.

4 participants