-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Minor clean-up #1112
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
Minor clean-up #1112
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1112 +/- ##
==========================================
+ Coverage 95.98% 96.11% +0.13%
==========================================
Files 64 64
Lines 4107 4096 -11
==========================================
- Hits 3942 3937 -5
+ Misses 165 159 -6
Continue to review full report at Codecov.
|
httpie/core.py
Outdated
| env=env, | ||
| ) | ||
| parsed_args = parser.parse_args(args=args, env=env) | ||
| exit_status = program(args=parsed_args, env=env) |
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.
parse_args() and program() each have their own try clause intentionally because we handle different types of exceptions for them. For example, we don’t handle base Exceptions from parse_args() as you can see. We also want to keep the try branches minimal and the distinction explicit. To get rid of the duplicate handling of SystemError and KeyboardInterrupt, something like this would be more in line with the intended behavior:
try:
parse_args()
try:
program()
except Timeout:
pass
except TooManyRedirects:
pass
except Exception:
pass
except KeyboardInterrupt:
pass
except SystemExit:
passThere 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.
This approach would come with the implicit requirement that the outer except types don’t inherit from Exception. So it would need at least a comment.
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.
Good catch. I removed the commit as it is not really interesting to change that part for now.
I had a look at tests coverage in the context of #1110 and saw 1-2 things that could be quickly tackled.