Commit f80405e
Fix deps with ~= version specifier treated as local paths (#3726)
## Summary
- Fix `deps = pre-commit ~= 4` being treated as a local path instead of
an invalid requirement
- Root cause: `packaging.Requirement()` rejects `~=` with single-segment
versions (PEP 440 requires 2+ segments), then tox's fallback treats the
`~` as a tilde home directory path
- Fix: detect PEP 440 version specifier operators before path detection,
keep the string as-is for pip to give a clear error
Closes #3447
## Test plan
- [x] Added parametrized test for `pre-commit ~= 4` and `pre-commit~=4`
- [x] All 104 req file tests pass
- [x] All 49 pip install tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent e84002a commit f80405e
3 files changed
Lines changed: 12 additions & 0 deletions
File tree
- docs/changelog
- src/tox/tox_env/python/pip/req
- tests/tox_env/python/pip/req
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
553 | 560 | | |
554 | 561 | | |
555 | 562 | | |
| |||
0 commit comments