- Notifications
You must be signed in to change notification settings - Fork689
Enhance readability of .python-version#1105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This PR improves the readability and functionality when reading the .python-version file by supporting multiple versions, handling pyenv-virtualenv pointers, ignoring comments and empty lines, and trimming whitespace.
- Updated the function name and logic in utils.ts to process multiple lines.
- Refactored setup-python.ts and updated tests intests/utils.test.ts to integrate the new behavior.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/utils.ts | Renamed and updated function to support multi-line version files and pointer handling. |
| src/setup-python.ts | Updated import and usage to reflect the new function name. |
| tests/utils.test.ts | Added tests for multi-line files and updated expected outcomes. |
| if(line.startsWith('#')||line.trim()===''){ | ||
| returnundefined; | ||
| } | ||
| letversion:string=line.trim(); |
CopilotAIMay 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
[nitpick] Consider caching the result of line.trim() in a variable to avoid calling trim() multiple times within the mapping function.
| if(line.startsWith('#')||line.trim()===''){ | |
| returnundefined; | |
| } | |
| letversion:string=line.trim(); | |
| consttrimmedLine=line.trim(); | |
| if(line.startsWith('#')||trimmedLine===''){ | |
| returnundefined; | |
| } | |
| letversion:string=trimmedLine; |
Uh oh!
There was an error while loading.Please reload this page.
Enhance reading from .python-version file, matching the Pyenv behavior:
3.10/envs/virtualenv)(seeDon't use
.python-versionfor auto-activation pyenv/pyenv-virtualenv#472)#We extend our thanks to@krystof-k for the valuable contribution in implementing this feature in PR#787. To expedite its availability to users, we have created this PR, which incorporates the same changes while addressing the CI issues that had previously delayed the merge of PR#787.
Check list: