feat(foundry): add python_version_minor computed field#56
Merged
olivermeyer merged 2 commits intomainfrom Apr 27, 2026
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
|
neelay-aign
reviewed
Apr 27, 2026
Comment on lines
+142
to
+144
| parts = self.python_version.split(".") | ||
| major_minor_part_count = 2 | ||
| return ".".join(parts[:major_minor_part_count]) if len(parts) >= major_minor_part_count else self.python_version |
There was a problem hiding this comment.
Am I missing something or would the following one-liner have the same behavior?
`
Suggested change
| parts = self.python_version.split(".") | |
| major_minor_part_count = 2 | |
| return ".".join(parts[:major_minor_part_count]) if len(parts) >= major_minor_part_count else self.python_version | |
| return ".".join(self.python_version.split(".")[:2]) |
Collaborator
Author
There was a problem hiding this comment.
I had this initially and ruff raised PLR2004 on the number comparison:
parts = self.python_version.split(".")
return ".".join(parts[:2]) if len(parts) >= 2 else self.python_versionBut good point that the if len(parts) ... is a bit convoluted. I'll do this as a middle ground:
major_minor_part_count = 2
return ".".join(self.python_version.split(".")[:major_minor_part_count])There was a problem hiding this comment.
Could be an appropriate place to use a # noqa IMO, especially to save tokens 😉. But also happy with this. Approved.
1256df2 to
461b8d6
Compare
|
neelay-aign
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why?
Callers that need only the
major.minorportion of the Python runtime version (e.g."3.11") currently have to repeat the same.split(".")[:2]derivation themselves. A dedicated field onFoundryContextmakes this consistently available without boilerplate.How?
Added
python_version_minoras a Pydantic v2@computed_fieldproperty onFoundryContext, derived from the existingpython_versionfield at access time. Returns""whenpython_versionis unset. Also addedpython_versionas an explicit parameter tomake_context()so tests can exercise the new field without reaching forfrom_package().