Skip to content

Add new parameter python_versions in copier.yml#35

Merged
mberz merged 2 commits intomainfrom
enhancement/new-python_versions-parameter
Feb 6, 2026
Merged

Add new parameter python_versions in copier.yml#35
mberz merged 2 commits intomainfrom
enhancement/new-python_versions-parameter

Conversation

@h-chmeruk
Copy link
Contributor

I noticed that for parameters related to Python versions, we create a new array with Python versions in several places. Later, this will require us to manually add new or remove old Python versions in each of these arrays.
To avoid this, we can add a new parameter that defines all available Python versions once and use it in all other parameters related to Python versions.

Changes proposed in this pull request:

  • Added a new parameter called python_versions to copier.yml, which defines all Python versions valid for the project.
  • The choices for the minimum_python_version parameter are now created from the new python_versions parameter.
  • The parameter valid_python_versions now also uses the new parameter python_versions to define the array of all available Python versions.
  • Adjusted the conftest.py file, since the Python versions are now stored with obligatory apostrophes ' ' as follows:
    "minimum_python_version": "'3.11'",

@h-chmeruk h-chmeruk added the enhancement New feature or request label Feb 5, 2026
@h-chmeruk h-chmeruk requested a review from ahms5 February 5, 2026 10:39
@h-chmeruk h-chmeruk added this to the v0.1.0 milestone Feb 5, 2026
@h-chmeruk h-chmeruk mentioned this pull request Feb 5, 2026
Copy link
Member

@ahms5 ahms5 left a comment

Choose a reason for hiding this comment

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

really nice feature, thank you. I just have a few comments.

copier.yml Outdated
python_versions:
when: false
type: yaml
default: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
Copy link
Member

Choose a reason for hiding this comment

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

maybe use " instead of ', be usually use ", even we dont have a strinkt rule. This might make the change in conftest.py obsolete.

"project_getting_started": "This is how to get started.",
"git_username": "pyfar",
"minimum_python_version": "3.11",
"minimum_python_version": "'3.11'",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"minimum_python_version": "'3.11'",
"minimum_python_version": "3.11",

Comment on lines +100 to +101
{% set min_index = python_versions.index(minimum_python_version) %}
{{ python_versions[min_index:] }}
Copy link
Member

Choose a reason for hiding this comment

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

really nice

copier.yml Outdated
- "3.14"
choices: >
{% for v in python_versions %}
- "'{{ v }}'"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- "'{{ v }}'"
- {{ v }}

do we really need them?

Copy link
Contributor Author

@h-chmeruk h-chmeruk Feb 6, 2026

Choose a reason for hiding this comment

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

Actually, yes. The entire implementation is a bit tricky, and I'm not sure I fully understand it, but here's what I noticed:

After defining default: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"], YAML stores it as python_versions = ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']. As soon as we try to create choices for minimum_python_version from python_versions, each element of the python_versions array is taken separately and treated as a float value. Since it is treated as a float value, the zero in 3.10 is removed and the choice is displayed as 3.1. And even if we put the choices in quotes, they will only be displayed correctly in the questions, but as soon as we select the choice with 3.10, it will be stored as a float, i.e. as 3.1. For this reason, we need to store the values as strings and not as floats...

But I've already noticed that I can just change the parameter type from yaml to str, so we only need a pair of quotation marks (to display the choices correctly).

@ahms5 ahms5 requested review from a team, ahms5 and hoyer-a February 6, 2026 14:05
@github-project-automation github-project-automation bot moved this from Backlog to Require review in Weekly Planning Feb 6, 2026
@ahms5 ahms5 removed their request for review February 6, 2026 14:06
@h-chmeruk h-chmeruk requested a review from ahms5 February 6, 2026 15:44
Copy link
Member

@ahms5 ahms5 left a comment

Choose a reason for hiding this comment

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

nice

@github-project-automation github-project-automation bot moved this from Require review to Reviewer Approved in Weekly Planning Feb 6, 2026
@mberz mberz merged commit 0f2308d into main Feb 6, 2026
11 checks passed
@github-project-automation github-project-automation bot moved this from Reviewer Approved to Done in Weekly Planning Feb 6, 2026
@mberz mberz deleted the enhancement/new-python_versions-parameter branch February 6, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants