Skip to content

Enhance readability of .python-version - #1105

Closed
lmvysakh wants to merge 1 commit into
actions:mainfrom
lmvysakh:enhance-python-version-readability
Closed

Enhance readability of .python-version#1105
lmvysakh wants to merge 1 commit into
actions:mainfrom
lmvysakh:enhance-python-version-readability

Conversation

@lmvysakh

@lmvysakhlmvysakh commented May 14, 2025

Copy link
Copy Markdown
Contributor

Enhance reading from .python-version file, matching the Pyenv behavior:

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:

  • Tests were added or updated to cover the changes.

CopilotAI review requested due to automatic review settings May 14, 2025 11:10
@lmvysakh
lmvysakh requested a review from a team as a code ownerMay 14, 2025 11:10

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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 in tests/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.

FileDescription
src/utils.tsRenamed and updated function to support multi-line version files and pointer handling.
src/setup-python.tsUpdated import and usage to reflect the new function name.
tests/utils.test.tsAdded tests for multi-line files and updated expected outcomes.

Comment threadsrc/utils.ts
Comment on lines +284 to +287
if (line.startsWith('#') || line.trim() === '') {
return undefined;
}
let version: string = line.trim();

CopilotAIMay 14, 2025

Copy link

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.

Suggested change
if(line.startsWith('#')||line.trim()===''){
returnundefined;
}
letversion: string=line.trim();
consttrimmedLine=line.trim();
if(line.startsWith('#')||trimmedLine===''){
returnundefined;
}
letversion: string=trimmedLine;

Copilot uses AI. Check for mistakes.
@krystof-kkrystof-k mentioned this pull request May 14, 2025
2 tasks
@lmvysakh

Copy link
Copy Markdown
ContributorAuthor

The relevant changes and improvements proposed here have already been addressed and implemented in PR #787. Hence, this PR is now superseded by #787, which provides a more comprehensive solution for the scenarios discussed. Therefore, we are closing this pull request.

Sign up for freeto 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.

4 participants

@lmvysakh@HarithaVattikuti@priya-kinthali