Support requirements without an extension#16889
Conversation
305c521 to
e9fd2f5
Compare
44e8062 to
d5dad4e
Compare
e9fd2f5 to
7554291
Compare
CodSpeed Performance ReportMerging #16889 will degrade performances by 28.44%Comparing Summary
Benchmarks breakdown
Footnotes |
| // If it's not a PEP 723 script, assume it's a `requirements.txt` file. | ||
| let requirements_txt = | ||
| RequirementsTxt::parse_str(&content, &path, &*CWD, client_builder, cache) | ||
| .await?; |
There was a problem hiding this comment.
We should special case the error message, asking the user to specify a format manually, as we defaulted to requirements.txt and that failed.
$ uv pip install -r .editorconfig
error: Couldn't parse requirement in `.editorconfig` at position 102
Caused by: no such comparison operator "=", must be one of ~= == != <= >= < > ===
root = true
^^^^^^
$ uv pip install -r uv.lock
error: Couldn't parse requirement in `uv.lock` at position 0
Caused by: no such comparison operator "=", must be one of ~= == != <= >= < > ===
version = 1
^^^
There was a problem hiding this comment.
There's not a way for them to specify the format though, right?
There was a problem hiding this comment.
We use the filename only, but currently there's no indication that this fails because we're trying to parse anything that doesn't look like a pylock.toml as requirements.txt
There was a problem hiding this comment.
I think the hint would just be "We tried to parse this as a requirements.txt because it doesn't have an supported extension"?
For uv.lock, see #16192
This PR un-reverts #16861 by resolving extensionless sources with a different strategy: we return an `Extensionless` variant, then infer the type when we read the file and parse the contents immediately after, thereby avoiding multiple reads.
Duplicate of #16889 since I merged it without realizing it was stacked. Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Summary
This PR un-reverts #16861 by resolving extensionless sources with a different strategy: we return an
Extensionlessvariant, then infer the type when we read the file and parse the contents immediately after, thereby avoiding multiple reads.