Skip to content
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

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

shubhbapna
Copy link
Collaborator

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

@mergify mergify bot added the ci label Nov 12, 2024
@shubhbapna shubhbapna force-pushed the use-url branch 2 times, most recently from b131625 to 2ec1d0c Compare November 13, 2024 14:31
) -> typing.Generator[io.TextIOWrapper, typing.Any, None]:
location = str(path_or_url)
if location.startswith(("https://", "http://", "file://")):
response = session.get(location)
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes sense

Copy link
Collaborator Author

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?

Copy link
Member

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]>
Copy link
Member

@dhellmann dhellmann left a 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)
Copy link
Member

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.

@mergify mergify bot merged commit f1bfa8b into python-wheel-build:main Dec 4, 2024
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow use of urls to read information from file
3 participants