-
-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special case enum option parse failures. #12281
Merged
Merged
Conversation
This file contains 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
Display the valid choices to be more helpful. Also eliminate an unuseful traceback from the option parse error message which always points to the same internal option parsing code call stack. Fixes pantsbuild#12277 [ci skip-rust] [ci skip-build-wheels]
Before: $ ./pants dependencies --no-print-stacktrace --type=x src/python/pants/util/::
21:48:50.98 [ERROR] Error computing value for --type in scope 'dependencies' (may also be from PANTS_* environment variables).
Caused by:
ValueError: 'x' is not a valid DependencyType
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/option/parser.py", line 582, in to_value_type
return type_arg(val_str)
File "/usr/lib/python3.7/enum.py", line 315, in __call__
return cls.__new__(cls, value)
File "/usr/lib/python3.7/enum.py", line 569, in __new__
raise exc
File "/usr/lib/python3.7/enum.py", line 553, in __new__
result = cls._missing_(value)
File "/usr/lib/python3.7/enum.py", line 582, in _missing_
raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 'x' is not a valid DependencyType
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/option/parser.py", line 284, in parse_args
dest, kwargs, flag_vals, parse_args_request.passthrough_args
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/option/parser.py", line 673, in _compute_value
flag_vals = [to_value_type(expand(x)) for x in flag_val_strs]
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/option/parser.py", line 673, in <listcomp>
flag_vals = [to_value_type(expand(x)) for x in flag_val_strs]
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/option/parser.py", line 617, in to_value_type
return self.to_value_type(val_str, type_arg, member_type, dest)
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/option/parser.py", line 585, in to_value_type
f"Error applying type '{type_arg.__name__}' to option value '{val_str}', "
pants.option.errors.ParseError: Error applying type 'DependencyType' to option value 'x', for option '--type' in scope 'dependencies': 'x' is not a valid DependencyType
(Use --print-stacktrace for more error details and/or --no-process-execution-local-cleanup to inspect chroots and/or -ldebug for more logs. See https://www.pantsbuild.org/v2.6/docs/troubleshooting for common issues. Consider reaching out for help: https://www.pantsbuild.org/v2.6/docs/getting-help.) After: $ ./pants dependencies --no-print-stacktrace --type=x src/python/pants/util/::
21:48:29.31 [ERROR] Error computing value for --type in scope 'dependencies' (may also be from PANTS_* environment variables).
Caused by:
Invalid choice 'x'. Choose from: source, 3rdparty, source-and-3rdparty
(Use --print-stacktrace for more error details and/or --no-process-execution-local-cleanup to inspect chroots and/or -ldebug for more logs. See https://www.pantsbuild.org/v2.6/docs/troubleshooting for common issues. Consider reaching out for help: https://www.pantsbuild.org/v2.6/docs/getting-help.) |
benjyw
approved these changes
Jul 5, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Eric-Arellano
approved these changes
Jul 6, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, John!
Merged
wisechengyi
added a commit
that referenced
this pull request
Jul 17, 2021
### Internal * [internal] Manually fix Black lockfile to handle interpreter constraints ([#12366](#12366)) * Revert "Prefix the entire setup.py chroot. (#12359)" ([#12370](#12370)) * [internal] Cache native client binary in CI ([#12355](#12355)) * Prefix the entire setup.py chroot. ([#12359](#12359)) * [internal] Fix AWS CLI breaking due to Python 2 usage ([#12364](#12364)) * [Internal] Add `git_url()` helper to `docutil.py` ([#12352](#12352)) * [Internal] Refactor how `PythonToolBase` exposes requirements and interpreter constraints ([#12356](#12356)) * [internal] Add experimental per-tool lockfiles with Docformatter as an example ([#12346](#12346)) * Remove Pants's dpeendency on `requests` ([#12348](#12348)) * [internal] Remove `TwoStepPex` abstraction ([#12343](#12343)) * Add psycopg2-binary to default module mapping ([#12339](#12339)) * [internal] Upgrade toolchain pants plugin to 0.13.1 ([#12338](#12338)) * Add an API to coarsen/partition Targets by their cycles ([#12251](#12251)) * Prepare 2.5.1 ([#12329](#12329)) * Bootstrap fewer JVM versions in Coursier/javac tests to hopefully reduce CI flakiness ([#12325](#12325)) * Native client respects `--concurrent`. ([#12324](#12324)) * Add client lib tests. ([#12322](#12322)) * Special case enum option parse failures. ([#12281](#12281))
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.
Display the valid choices to be more helpful. Also eliminate an unuseful
traceback from the option parse error message which always points to the
same internal option parsing code call stack.
Fixes #12277
[ci skip-rust]
[ci skip-build-wheels]