Skip to content

Conversation

@rd4398
Copy link
Contributor

@rd4398 rd4398 commented Aug 30, 2024

Fixes: #361

@mergify mergify bot added the ci label Aug 30, 2024
@rd4398 rd4398 marked this pull request as draft August 30, 2024 16:40
@rd4398 rd4398 marked this pull request as ready for review August 30, 2024 18:00
Copy link
Contributor

@shubhbapna shubhbapna left a comment

Choose a reason for hiding this comment

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

Instead of passing it in context, should we create a module instead that exposes this session object. Then instead of passing the context everywhere, we just import the session object?

@rd4398
Copy link
Contributor Author

rd4398 commented Aug 30, 2024

Instead of passing it in context, should we create a module instead that exposes this session object. Then instead of passing the context everywhere, we just import the session object?

I had tried separate module few weeks ago in #228
The suggestions made there is why I am doing this in context instead of separate module

@shubhbapna
Copy link
Contributor

I had tried separate module few weeks ago in #228
The suggestions made there is why I am doing this in context instead of separate module

Oh is this the module: 4cc20c8 ? The module in this commit defines a class but there is no object that can be used directly on importing. I was thinking something along these lines:

request_session.py:

import request
session = request.session()

Then say in resolver.py:

from .request_session import session

# the function signature doesn't change at all
def get_project_from_pypi(
    project: str,
    extras: typing.Iterable[str],
    sdist_server_url: str,
) -> typing.Iterable[Candidate]:
    """Return candidates created from the project name and extras."""
    simple_index_url = sdist_server_url.rstrip("/") + "/" + project + "/"
    logger.debug("%s: getting available versions from %s", project, simple_index_url)
    # using the session object directly
    data = session.get(simple_index_url).content

@rd4398
Copy link
Contributor Author

rd4398 commented Aug 30, 2024

I had tried separate module few weeks ago in #228
The suggestions made there is why I am doing this in context instead of separate module

Oh is this the module: 4cc20c8 ? The module in this commit defines a class but there is no object that can be used directly on importing. I was thinking something along these lines:

request_session.py:

import request
session = request.session()

Then say in resolver.py:

from .request_session import session

# the function signature doesn't change at all
def get_project_from_pypi(
    project: str,
    extras: typing.Iterable[str],
    sdist_server_url: str,
) -> typing.Iterable[Candidate]:
    """Return candidates created from the project name and extras."""
    simple_index_url = sdist_server_url.rstrip("/") + "/" + project + "/"
    logger.debug("%s: getting available versions from %s", project, simple_index_url)
    # using the session object directly
    data = session.get(simple_index_url).content

yeah, that's the one.
Hmm okay, I can do that

@rd4398
Copy link
Contributor Author

rd4398 commented Aug 30, 2024

I had tried separate module few weeks ago in #228
The suggestions made there is why I am doing this in context instead of separate module

Oh is this the module: 4cc20c8 ? The module in this commit defines a class but there is no object that can be used directly on importing. I was thinking something along these lines:
request_session.py:

import request
session = request.session()

Then say in resolver.py:

from .request_session import session

# the function signature doesn't change at all
def get_project_from_pypi(
    project: str,
    extras: typing.Iterable[str],
    sdist_server_url: str,
) -> typing.Iterable[Candidate]:
    """Return candidates created from the project name and extras."""
    simple_index_url = sdist_server_url.rstrip("/") + "/" + project + "/"
    logger.debug("%s: getting available versions from %s", project, simple_index_url)
    # using the session object directly
    data = session.get(simple_index_url).content

yeah, that's the one. Hmm okay, I can do that

Done

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.

A couple of nits, but this generally looks good.

@dhellmann
Copy link
Member

I'm happy with this version. @shubhbapna had comments, so I'll leave it open for him to review.

I re-ran the coverage job that failed and it failed again. Is that a known problem?

@rd4398
Copy link
Contributor Author

rd4398 commented Sep 3, 2024

I'm happy with this version. @shubhbapna had comments, so I'll leave it open for him to review.

I re-ran the coverage job that failed and it failed again. Is that a known problem?

I am not sure. I am seeing it for the first time

Copy link
Contributor

@shubhbapna shubhbapna left a comment

Choose a reason for hiding this comment

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

LGTM! I reran the checks in hopes of regenerating the coverage files. The coverage job was failing because no artifacts were found for some reason

@mergify mergify bot merged commit 8626255 into main Sep 3, 2024
@dhellmann dhellmann deleted the issue-#361 branch September 6, 2024 15:43
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.

Reuse requests session

4 participants