DEV Community

Cover image for Your Python version is pinned in 7 places. Here they are.
Versyka
Versyka

Posted on AI-assisted

Your Python version is pinned in 7 places. Here they are.

Stop: your Python version hides in 7 places. Don't miss 1. Miss one and you get the worst kind of bug: CI on 3.12, production on 3.10, and green tests in the wrong place.

You won't have all seven. You'll have three or four, and that's exactly how one gets missed.

The seven

  1. .python-version: pyenv, uv and many editors read it.
  2. runtime.txt: Heroku-style platforms (python-3.10.14).
  3. Dockerfile: FROM python:3.10-slim. Keep the variant (-slim, -alpine, -bookworm) when you change the version.
  4. CI workflows: python-version: "3.10" in setup-python, and matrix entries.
  5. pyproject.toml: requires-python = ">=3.10,<3.11" can exclude the new version.
  6. Pipfile: python_version = "3.10".
  7. .tool-versions: asdf and mise.

Also worth a search: tox.ini/noxfile.py environments, setup.cfg python_requires, serverless configs (runtime: python3.10).

One search for all of them

grep -rnE "3\.10|python3\.10|py310" \
  --include=.python-version --include=runtime.txt --include=Dockerfile* \
  --include=*.yml --include=*.yaml --include=*.toml --include=Pipfile \
  --include=.tool-versions .
Enter fullscreen mode Exit fullscreen mode

Change them in one commit

Splitting the change across commits is how CI and production drift apart. One pull request, every file, then run the tests on the new version.

Versyka changes every place together and lists what it shouldn't decide for you, like a test matrix you may want to keep wide.

Which of the seven did you forget last time?

Top comments (0)