-
Notifications
You must be signed in to change notification settings - Fork 171
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
Improve CLI error messages #37
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
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.
Looks great! Just a couple test improvements.
tests/test_cli.py
Outdated
@@ -81,7 +81,7 @@ def test_no_traces(store_data, stdout, stderr): | |||
store, db_file = store_data | |||
with mock.patch.dict(os.environ, {DefaultConfig.DB_PATH_VAR: db_file.name}): | |||
ret = cli.main(['stub', func.__module__], stdout, stderr) | |||
assert stderr.getvalue() == "No traces found\n" | |||
assert stderr.getvalue().startswith("No traces found") |
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.
Shouldn't we be able to use func.__module__
again here and assert on the full error message?
c52f2aa
to
100c506
Compare
@carljm Tests added :) |
tests/test_cli.py
Outdated
@@ -81,7 +81,7 @@ def test_no_traces(store_data, stdout, stderr): | |||
store, db_file = store_data | |||
with mock.patch.dict(os.environ, {DefaultConfig.DB_PATH_VAR: db_file.name}): | |||
ret = cli.main(['stub', func.__module__], stdout, stderr) | |||
assert stderr.getvalue() == "No traces found\n" | |||
assert stderr.getvalue() == f"No traces found for module path ('{func.__module__}', None)\n" |
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.
I think this (module, qualname)
representation will be confusing, especially when qualname is None
(which is the more common case). Can we rejoin the tuple into its original form instead? (Or maybe there is some argparse way to preserve the original pre-parsing string?)
@akx - This PR is close to being ready to go. Are you still planning on working on it? |
933418b
to
50c8652
Compare
@mpage Yes, sorry I'd left this hanging! In my defense I spent two weeks in Japan in the interim and it was pretty. @carljm Changes made! :) |
@akx - Looks great - can you fix the conflicts? |
Looks great! Thanks for pushing this through! Merging. |
This PR makes the CLI error messages a little more explicit.
I was trying to mistakenly pass in file system paths for modules, which didn't work. :)