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

Version 0.14.0 #1083

Merged
merged 13 commits into from
Aug 7, 2020
Merged

Version 0.14.0 #1083

merged 13 commits into from
Aug 7, 2020

Conversation

tomchristie
Copy link
Member

@tomchristie tomchristie commented Jul 24, 2020

0.14.0 (August 7th, 2020)

The 0.14 release includes a range of improvements to the public API, intended on preparing for our upcoming 1.0 release.

  • Our HTTP/2 support is now fully optional. You now need to use pip install httpx[http2] if you want to include the HTTP/2 dependancies.
  • Our HSTS support has now been removed. Rewriting URLs from http to https if the host is on the HSTS list can be beneficial in avoiding roundtrips to incorrectly formed URLs, but on balance we've decided to remove this feature, on the principle of least surprise. Most programmatic clients do not include HSTS support, and for now we're opting to remove our support for it.
  • Our exception hierarchy has been overhauled. Most users will want to stick with their existing httpx.HTTPError usage, but we've got a clearer overall structure now. See https://www.python-httpx.org/exceptions/ for more details.

When upgrading you should be aware of the following public API changes. Note that deprecated usages will currently continue to function, but will issue warnings.

  • You should now use httpx.codes consistently in favour of httpx.StatusCodes.
  • Usage of httpx.Timeout() should now always include an explicit default. Eg. httpx.Timeout(None, pool=5.0).
  • When using httpx.Timeout(), we now have more concisely named keyword arguments. Eg. read=5.0, instead of read_timeout=5.0.
  • Use httpx.Limits() instead of httpx.PoolLimits(), and limits=... instead of pool_limits=....
  • The httpx.Limits(max_keepalive=...) argument is now deprecated in favour of a more explicit httpx.Limits(max_keepalive_connections=...)
  • Keys used with Client(proxies={...}) should now be in the style of {"http://": ...}, rather than {"http": ...}.
  • The multidict methods Headers.getlist() and QueryParams.getlist() are deprecated in favour of more consistent .get_list() variants.
  • The URL.is_ssl property is deprecated in favour of URL.scheme == "https".
  • The URL.join(relative_url=...) method is now URL.join(url=...). This change does not support warnings for the deprecated usage style.

One notable aspect of the 0.14.0 release is that it tightens up the public API for httpx, by ensuring that several internal attributes and methods have now become strictly private.

The following previously had nominally public names on the client, but were all undocumented and intended solely for internal usage. They are all now replaced with underscored names, and should not be relied on or accessed.

These changes should not affect users who have been working from the httpx documentation.

  • .merge_url(), .merge_headers(), .merge_cookies(), .merge_queryparams()
  • .build_auth(), .build_redirect_request()
  • .redirect_method(), .redirect_url(), .redirect_headers(), .redirect_stream()
  • .send_handling_redirects(), .send_handling_auth(), .send_single_request()
  • .init_transport(), .init_proxy_transport()
  • .proxies, .transport, .netrc, .get_proxy_map()

See pull requests #997, #1065, #1071.

Some areas of API which were already on the deprecation path, and were raising warnings or errors in 0.13.x have now been escalated to being fully removed.

  • Drop ASGIDispatch, WSGIDispatch, which have been replaced by ASGITransport, WSGITransport.
  • Drop dispatch=...`` on client, which has been replaced by transport=...``
  • Drop soft_limit, hard_limit, which have been replaced by max_keepalive and max_connections.
  • Drop Response.stream and Response.raw, which have been replaced by ``.aiter_bytes and .aiter_raw.
  • Drop proxies=<transport instance> in favor of proxies=httpx.Proxy(...).

See pull requests #1057, #1058.

### Added

Changed

Fixed

@tomchristie tomchristie added the do not merge PRs that should not be merged label Jul 24, 2020
@tomchristie
Copy link
Member Author

tomchristie commented Jul 24, 2020

Other possible candidates for a 0.14.0 release...

  • Add httpx.create_ssl_context() helper function. Included create_ssl_context function to create the same context with SSLConfig and serve as API #996
  • Use limits=... and httpx.Limits instead of pool_limits and httpx.PoolLimits, with a gentle deprecation path. I've been meaning to mention this. Particularly applicable if eg. at some point we wanted some more general client-wide "max concurrent requests" controls, which isn't strictly to do with connection pooling.
  • Drop httpx.StatusCodes being exposed externally, since we document it's usage as httpx.codes.

I'm also minded to have a proper pass at polishing up the developer interface docs alongside the 0.14 release, since this release is really all about nailing that right down.

There are still some very minor bits of public/private attribute polishing that we'll want to look at on some of the models.

Excluding exceptions, here's how the public API shapes up after all this:

Helper functions

request, stream, get, options, head, post, put, patch, delete

Clients

Client, AsyncClient

Models

Response, Request, URL, QueryParams, Headers, Cookies

Configuration

Limits, Proxy, Timeout

Authentication

Auth, BasicAuth, DigestAuth

Transports

ASGITransport, WSGITransport

Status Codes

codes

@tomchristie tomchristie added this to the v0.14 milestone Jul 27, 2020
@tomchristie
Copy link
Member Author

tomchristie commented Aug 2, 2020

Hoping to roll the 0.14 release early this coming week.

Here's what I think we still need to do...

Anything I'm missing?

@tomchristie
Copy link
Member Author

  • Module level deprecation warning for HTTPError, and consider making it a two tuple of (RequestError, HTTPStatusError).

@florimondmanca
Copy link
Member

florimondmanca commented Aug 2, 2020

@tomchristie I won't be available most of the rest of today for reviews, neither on Monday. Is there such an urgent need to release 0.14 "ASAP"? I understand we're all excited but just an explicit heads up that I don't think this means we should bypass reviews on non-trivial changes (since I'm assuming merging w/o thorough second review would be the only way to achieve a release by tomorrow given the rest of things that need to be done). 😅

@tomchristie
Copy link
Member Author

Yup, all fair. Let's keep it moderated. It's a great piece of work, no need for us to rush it tho.

@iwoloschin
Copy link

  • Module level deprecation warning for HTTPError, and consider making it a two tuple of (RequestError, HTTPStatusError).

I think we really want this in some form that doesn't explicitly break existing codebases. If we can find a way to print a deprecation warning that's great, but if not just putting a big warning in the release notes is sufficient (yay for pre-1.0 code!).

@tomchristie
Copy link
Member Author

@iwoloschin Indeed. I think there's probably also a decent case to make for not deprecating it at all, and instead keeping it as a base class, but only for RequestError and HTTPStatusError, so that...

try:
    response = httpx.get("https://www.example.com/")  # May raise a RequestError subclass
    response.raise_for_status()  # May raise HTTPStatusError
except httpx.HTTPError as exc:
    pass

Which means existing code all keeps working as expected, while still providing finer-grained classes where needed.

Also, both HTTPStatusError and RequestError provide .request, so we can suitably annotate that on the base class.

It's also more concise than the alternative...

try:
    response = httpx.get("https://www.example.com/")  # May raise a RequestError subclass
    response.raise_for_status()  # May raise HTTPStatusError
except (httpx.RequestError, httpx.HTTPStatusError) as exc:
    pass

This hadn't really occurred to me when looking at #1095.

CHANGELOG.md Outdated Show resolved Hide resolved
tomchristie and others added 2 commits August 6, 2020 12:27
@tomchristie
Copy link
Member Author

tomchristie commented Aug 6, 2020

Last bits here are...

@tomchristie tomchristie removed the do not merge PRs that should not be merged label Aug 7, 2020
@tomchristie tomchristie merged commit 8c7729e into master Aug 7, 2020
@tomchristie tomchristie deleted the version-0.14.0 branch August 7, 2020 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants