Skip to content

Fix Python version detection in GitHub Actions workflows#2

Merged
MauGx3 merged 2 commits intomainfrom
copilot/fix-python-version-discovery
Oct 16, 2025
Merged

Fix Python version detection in GitHub Actions workflows#2
MauGx3 merged 2 commits intomainfrom
copilot/fix-python-version-discovery

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 16, 2025

Problem

The tests were failing because Python versions were not being discovered properly in GitHub Actions workflows. The workflows were attempting to use Python 3.1 instead of Python 3.10, causing setup failures.

Root Cause

YAML treats unquoted decimal numbers as floats, which causes trailing zeros to be dropped. When the workflow files specified python-version: [3.10, 3.11], YAML parsed these as:

  • 3.103.1 (float, losing the trailing zero)
  • 3.113.11 (float, no trailing zero to lose)

This resulted in GitHub Actions attempting to install Python 3.1, which doesn't exist in modern Python versions.

Solution

Quote the Python version numbers to ensure they are treated as strings rather than floats:

Before:

python-version: [3.10, 3.11]

After:

python-version: ["3.10", "3.11"]

Changes

  • Updated .github/workflows/pytest.yml to quote Python versions: ["3.10", "3.11"]
  • Updated .github/workflows/pyright.yml to quote Python version: ["3.10"]

Verification

Tested with Python's YAML parser to confirm the fix:

import yaml

# Unquoted (broken)
yaml.safe_load("v: [3.10]")  # {'v': [3.1]}

# Quoted (fixed)
yaml.safe_load('v: ["3.10"]')  # {'v': ['3.10']}

This is a common YAML gotcha when working with version numbers that have trailing zeros. The fix ensures GitHub Actions will correctly discover and use Python 3.10 and 3.11.

Original prompt

the tests are failing because the python versions are not being discovered properly, the tests look for version 3.1 instead of 3.10


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: MauGx3 <225707+MauGx3@users.noreply.github.com>
@MauGx3 MauGx3 marked this pull request as ready for review October 16, 2025 01:31
Copilot AI changed the title [WIP] Fix test discovery for correct Python version Fix Python version detection in GitHub Actions workflows Oct 16, 2025
@MauGx3 MauGx3 merged commit 199c5c5 into main Oct 16, 2025
0 of 2 checks passed
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.

2 participants