wheelgap diff with a missing file prints FileNotFoundError: [Errno 2] and the absolute path

Open Beginner friendly
#728 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start in _main() in src/wheelgap/diff.py, at the except Exception as e: block that formats type(e).__name__; compare it with how src/wheelgap/cli.py handles SourceError, TargetError, DockerfileError and OSError. Add an existence check for plain paths before reading each side and raise SourceError(f"{label}: no such file") with the argument as typed, leaving REF:PATH and --deps handling alone. Then add the missing-OLD and missing-NEW cases to tests/test_diff.py (exit 2, stderr wording, --json keys) using fake_pypi, and run that test file to check they pass where they failed before.

Written by the indexing model from the issue text.

Description

bug good first issue

wheelgap diff with an OLD or NEW file that doesn't exist prints Python's exception name and the absolute path, where the main command says nope.txt: no such file:

Reproduced with the released uvx wheelgap==0.14.0 (same code on main):

$ printf 'idna==3.10\n' > requirements.txt
$ uvx wheelgap==0.14.0 diff nope.txt requirements.txt -p 3.13 -t linux-x86_64
wheelgap: error: FileNotFoundError: [Errno 2] No such file or directory: '/home/me/project/nope.txt'
$ uvx wheelgap==0.14.0 nope.txt -p 3.13 -t linux-x86_64
wheelgap: error: nope.txt: no such file

A typo in the path is the most common way to hit this, and the absolute path makes it harder to see which argument was wrong.

Where

_main() in src/wheelgap/diff.py: the except Exception as e: at the end of the input-reading block prints f"{type(e).__name__}: {e}" for everything. The main command (src/wheelgap/cli.py) prints SourceError, TargetError, DockerfileError and OSError without the type name, and only adds it for unexpected errors.

What to do

  • Before reading each side, if it's a plain path (not git's REF:PATH, not a --deps spec) and doesn't exist, raise SourceError(f"{label}: no such file") with the argument as typed.
  • Optional, in the same PR if it stays small: print SourceError and TargetError without the type-name prefix, as the main command does. Say in the PR which messages change.

Done when

  • Tests in tests/test_diff.py: a missing OLD and a missing NEW each exit 2 with nope.txt: no such file on stderr (the path as typed, no Errno). With --json, the error object has the same keys (message, type). They fail on main.
  • A REF:PATH that git can't read still gives git's error, as now.
  • No network in the tests (fake_pypi).
  • One CHANGELOG.md bullet under ## Unreleased.
Dominant language
Python
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from patrickballard/wheelgap

All issues in patrickballard/wheelgap

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.