8000 Enhance readability of .python-version by lmvysakh · Pull Request #1105 · actions/setup-python · GitHub
[go: up one dir, main page]

Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lmvysakh
Copy link
@lmvysakh lmvysakh commented May 14, 2025

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 8000 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.

@Copilot Copilot AI review requested due to automatic review settings May 14, 2025 11:10
@lmvysakh lmvysakh requested a review from a team as a code owner May 14, 2025 11:10
Copy link
@Copilot Copilot AI left a 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 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.

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.

Comment on lines +284 to +287
if (line.startsWith('#') || line.trim() === '') {
return undefined;
}
let version: string = line.trim();
Copy link
Preview
Copilot AI May 14, 2025

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() === '') {
return undefined;
}
let version: string = line.trim();
const trimmedLine = line.trim();
if (line.startsWith('#') || trimmedLine === '') {
return undefined;
}
let version: string = trimmedLine;

Copilot uses AI. Check for mistakes.

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
0