Skip to content

Commit

Permalink
MAINT: remove .python-version if requires-python pins
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Oct 28, 2024
1 parent 767f680 commit 6513ad9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/compwa_policy/check_dev_files/uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ def _update_editor_config() -> None:


def _update_python_version_file(dev_python_version: PythonVersion) -> None:
pyproject = Pyproject.load()
python_version_file = Path(".python-version")
if pyproject.has_table("project"):
requires_python = pyproject.get_table("project").get("requires-python", "")
if "==" in requires_python or "~=" in requires_python:
if python_version_file.exists():
python_version_file.unlink()
msg = f"Removed {python_version_file} file because requires-python already pins the Python version"
raise PrecommitError(msg)
return

existing_python_version = ""
if python_version_file.exists():
with open(python_version_file) as stream:
Expand Down

0 comments on commit 6513ad9

Please sign in to comment.