-
Notifications
You must be signed in to change notification settings - Fork 13
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
allow use of url for req, constraint and graph files #504
Conversation
b131625
to
2ec1d0c
Compare
) -> typing.Generator[io.TextIOWrapper, typing.Any, None]: | ||
location = str(path_or_url) | ||
if location.startswith(("https://", "http://", "file://")): | ||
response = session.get(location) |
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.
session.get() and open() will produce different types of exceptions, so every caller using this function would have to handle both exception types. That leaks details of the implementation outside of the function.
We can keep it like this in this MR, but it would be better to trap the exceptions and produce a common one that is advertised as the API for this function.
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.
Ah that makes sense
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.
Actually won't it help during debugging if the exceptions were different?
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.
If you do raise IOError('local message') from err
then the caller only has to catch IOError
, and the traceback shows all of the details of the original exception.
users can now pass a url instead of a path to a local file to commands that need req files, constraints file or graph files. pip allows using url for req and constraints file so this is a pip compatible change Signed-off-by: Shubh Bapna <[email protected]>
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.
We can deal with the exception handling in another PR.
) -> typing.Generator[io.TextIOWrapper, typing.Any, None]: | ||
location = str(path_or_url) | ||
if location.startswith(("https://", "http://", "file://")): | ||
response = session.get(location) |
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.
If you do raise IOError('local message') from err
then the caller only has to catch IOError
, and the traceback shows all of the details of the original exception.
fixes #501
users can now pass a url instead of a path to a local file to commands that need req files, constraints file or graph files. pip allows using url for req and constraints file so this is a pip compatible change