Skip to content

Support bare local file paths in dependency parsing#10911

Open
Mirochill wants to merge 4 commits into
python-poetry:mainfrom
Mirochill:fix-6951-bare-file-path
Open

Support bare local file paths in dependency parsing#10911
Mirochill wants to merge 4 commits into
python-poetry:mainfrom
Mirochill:fix-6951-bare-file-path

Conversation

@Mirochill
Copy link
Copy Markdown
Contributor

@Mirochill Mirochill commented May 18, 2026

Pull Request Check List

Resolves: #6951

Summary

  • accept an existing local file like demo.whl as a path dependency even when the argument has no directory separator
  • keep separator-less directory names on the simple-package path, so this only broadens the file case reported in the issue
  • add a regression test for a bare local wheel filename

Validation

  • Not run locally

  • Added tests for changed code.

  • Updated documentation for changed code.

@Mirochill Mirochill force-pushed the fix-6951-bare-file-path branch 4 times, most recently from d740c2e to 0398859 Compare May 18, 2026 18:45
@Mirochill Mirochill marked this pull request as ready for review May 18, 2026 18:54
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new parse() logic now hits the filesystem for every separator-less requirement; consider limiting the early _parse_path check to names that look like files (e.g., known archive extensions) to avoid unnecessary stat calls for typical package specs.
  • In _parse_path, is_relative_file is a subset of is_relative_path, so the condition (is_explicit_path && is_relative_path) || is_relative_file can be simplified (or commented) to make the intended cases clearer and reduce mental overhead when reasoning about path handling.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `parse()` logic now hits the filesystem for every separator-less requirement; consider limiting the early `_parse_path` check to names that look like files (e.g., known archive extensions) to avoid unnecessary `stat` calls for typical package specs.
- In `_parse_path`, `is_relative_file` is a subset of `is_relative_path`, so the condition `(is_explicit_path && is_relative_path) || is_relative_file` can be simplified (or commented) to make the intended cases clearer and reduce mental overhead when reasoning about path handling.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Member

@radoering radoering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the sourcery feedback in #10911 (review) makes sense and should be addressed.

@Mirochill Mirochill force-pushed the fix-6951-bare-file-path branch from 0398859 to c1782ea Compare May 24, 2026 16:16
@Mirochill
Copy link
Copy Markdown
Contributor Author

Thanks, addressed in the latest branch updates. The parser now only probes local paths before or during fallback parsing when the requirement is explicit path-like or a known package archive filename, so plain package names avoid the filesystem path check. _parse_path() also uses the simplified relative/absolute path condition. The latest GitHub Actions matrix, Cirrus FreeBSD, and pre-commit.ci checks are green on 887f055.

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.

poetry add does not support paths without a directory component

2 participants