-
Notifications
You must be signed in to change notification settings - Fork 32
Refactor: Extract Python package validation to dedicated pip_validation.go #3319
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
Refactor: Extract Python package validation to dedicated pip_validation.go #3319
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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 refactors Python package validation code by separating validation logic from extraction logic. The validation functions (validatePipPackages, validateUvPackages, validatePythonPackagesWithPip, validateUvPackagesWithPip) are moved from pip.go to a new file pip_validation.go, while pip.go is simplified to focus solely on package extraction.
Key Changes
- Created new
pip_validation.gofile containing all Python package validation logic - Updated
pip.goto focus exclusively on package extraction functions - Updated documentation in both files to reflect their distinct responsibilities
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/workflow/pip_validation.go | New file containing Python package validation functions for pip and uv packages using PyPI index |
| pkg/workflow/pip.go | Simplified to contain only package extraction functions; removed all validation logic and updated documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Use uv pip show to check if package exists on PyPI | ||
| cmd := exec.Command("uv", "pip", "show", pkgName, "--no-cache") | ||
| _, err := cmd.CombinedOutput() | ||
|
|
||
| if err != nil { | ||
| // Package not installed, try to check if it's available | ||
| errors = append(errors, fmt.Sprintf("uv package '%s' validation requires network access or local cache", pkg)) |
Copilot
AI
Nov 6, 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.
The uv pip show command checks if a package is already installed locally, not if it exists on PyPI. This will fail for packages that aren't installed, even if they exist on PyPI. Consider using uv pip index or falling back to pip validation similar to the fallback pattern already implemented in lines 126-142.
| // Use uv pip show to check if package exists on PyPI | |
| cmd := exec.Command("uv", "pip", "show", pkgName, "--no-cache") | |
| _, err := cmd.CombinedOutput() | |
| if err != nil { | |
| // Package not installed, try to check if it's available | |
| errors = append(errors, fmt.Sprintf("uv package '%s' validation requires network access or local cache", pkg)) | |
| // Use uv pip index versions to check if package exists on PyPI | |
| cmd := exec.Command("uv", "pip", "index", "versions", pkgName) | |
| _, err := cmd.CombinedOutput() | |
| if err != nil { | |
| // Package not found on PyPI or network/cache issue | |
| errors = append(errors, fmt.Sprintf("uv package '%s' not found on PyPI or validation requires network access", pkg)) |
Consolidates Python package validation logic by extracting validation functions from
pip.gointo a dedicatedpip_validation.gofile, following the repository's domain-specific validation pattern.Changes
Created
pkg/workflow/pip_validation.go(178 lines)validatePythonPackagesWithPip(),validatePipPackages(),validateUvPackages(),validateUvPackagesWithPip()pipValidationLogfor validation-specific loggingRefactored
pkg/workflow/pip.go(reduced from 258 to 111 lines)extractPipPackages(),extractPipFromCommands(),extractUvPackages(),extractUvFromCommands()Structure
This mirrors the existing
npm.gopattern and avoids adding to the already largevalidation.go(850+ lines).Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.