Package metadata: give more-descriptive error when license file not found#827
Merged
radoering merged 3 commits intopython-poetry:mainfrom Jan 26, 2025
Conversation
Reviewer's Guide by SourceryThis pull request improves error handling when a license file is not found. Instead of failing silently, it now raises a FileNotFoundError with a descriptive message, which includes the absolute path of the missing file. Additionally, a test case was added to verify this new behavior. Sequence diagram for improved license file handlingsequenceDiagram
participant Factory as Factory._configure_package_metadata
participant FS as File System
Factory->>FS: Check if license_path exists
alt License file not found
FS-->>Factory: File does not exist
Factory->>Factory: Raise FileNotFoundError with detailed message
else License file exists
FS-->>Factory: File exists
Factory->>FS: Read license file content
FS-->>Factory: Return license text
Factory->>Factory: Process license text
end
Flow diagram for license file processingflowchart TD
A[Start license processing] --> B{Has license file path?}
B -->|No| C[Use raw license text]
B -->|Yes| D{Check if file exists}
D -->|No| E[Raise FileNotFoundError]
D -->|Yes| F[Read license file]
F --> G[Process license content]
C --> G
G --> H[End]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
2 tasks
There was a problem hiding this comment.
Hey @MaddyGuthridge - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟡 Security: 1 issue found
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
3d56aba to
f774027
Compare
radoering
requested changes
Jan 26, 2025
Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com>
radoering
approved these changes
Jan 26, 2025
3 tasks
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.
Resolves: python-poetry#10105
This is a second (much simpler) attempt at solving this issue. My first can be found at #825, and is massively more complex.
This time, the change is in
Factory._configure_package_metadata, and just adds aFileNotFoundErrorexception. Much easier to comprehend.One thing I want to check is how this error is reported by poetry's main CLI. I want to make sure that the detail of the error is properly conveyed in the CLI. Does anyone have advice on how I can test my modifications against the Poetry CLI?
Summary by Sourcery
Raise a FileNotFoundError when the license file specified in pyproject.toml is not found.
Bug Fixes:
Tests: