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

Add httpx.Mounts transport class. #3070

Closed
wants to merge 9 commits into from
Closed

Add httpx.Mounts transport class. #3070

wants to merge 9 commits into from

Conversation

tomchristie
Copy link
Member

@tomchristie tomchristie commented Jan 25, 2024

Discussed in #947 (comment)

This PR adds the Mounts and AsyncMounts transport classes.

Currently in draft... switch mounts=... out of the Client class directly.


Here's the synopsis...

We currently have mounts=... behaviour backed directly into the client, like so...

client = httpx.Client(mounts=...)

However it'd be neater to keep that complexity encapsulated within a transport class that supports routing, so...

transport = httpx.Mounts(...)
client = httpx.Client(transport=transport)

At this point in time the pull request replicates the mounts=... functionality in a transport class, but doesn't yet remove it from the client. A follow-up would deal with removing it.

@tomchristie tomchristie added the 1.0 proposal Pull requests proposing 1.0 API changes label Jan 25, 2024
return True

@property
def priority(self) -> typing.Tuple[int, int, int]:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def priority(self) -> typing.Tuple[int, int, int]:
def priority(self) -> tuple[int, int, int]:

Now we support this :)

Copy link
Member

Choose a reason for hiding this comment

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

Do we need CI check for this? Check out https://github.com/frostming/fix-future-annotations

Copy link
Member

Choose a reason for hiding this comment

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

@Kludex what do you think?

@tomchristie tomchristie changed the title Add Mounts transport class. Add httpx.Mounts transport class. Jan 25, 2024
pass


class URLPattern:
Copy link
Contributor

Choose a reason for hiding this comment

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

why duplicating it from httpx._utils?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well caught... because this pull request will also include removing mounts=... from the client, but I haven't gotten to that part yet.

It'll make more sense for all the implementation to be together in this module once the functionality is fully encompassed by httpx.Mounts().

@tomchristie tomchristie deleted the mounts branch September 27, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 proposal Pull requests proposing 1.0 API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants