Repository navigation
Conversation
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.
Running
versioningitin a directory that is not under versioncontrol but contains a
PKG-INFOfile without aVersionfield crasheswith an unhandled
ValueErrortraceback:Every other user-facing failure in
main()is reported as a cleanone-line
versioningit: <ErrorType>: <message>on stderr with a nonzeroexit status. A
PKG-INFOfile without aVersionfield is just as mucha user/input problem (e.g. a truncated or hand-written file), so it
should be reported the same way.
This change converts the
ValueErrorfromparse_version_from_metadata()into a
NotSdistErrorinsideget_version_from_pkg_info(), so the CLInow prints:
and exits 1 with no traceback.
parse_version_from_metadata()itself isunchanged (it still raises
ValueError, as documented and tested), andthe
--tracebackflag still shows the full traceback when requested.Test: added
test_command_bad_pkg_infototest/test_main.py, whichbuilds a project dir with a
[tool.versioningit]config plus aVersion-lessPKG-INFO, runsmain(), and asserts exit status 1,empty stdout, no
Tracebackon stderr, and aversioningit: NotSdistError:message. The new test fails before the fix (uncaughtValueError) and passes after;test_main.py,test_get_version.py,test_util.py, andtest_logging.pyall pass (199 passed, 1 skipped).