Commit Graph

1520 Commits

Author SHA1 Message Date
Tom Christie
ceccb964e6
Update butterfly logo (#1382) 2020-11-10 10:16:07 +00:00
Kyungmin Lee
84dca25b8e
Fix typo (#1386)
* Fix typo

three greater-than signs -> three dots

* Fix typo

three greater-than signs -> three dots

* Fix typo

three greater-than signs -> three dots
2020-11-08 10:28:38 +01:00
plotski
589c6e0f2f
Include invalid name/value when raising TypeError in DataField (#1368) 2020-11-05 10:46:22 +00:00
Aber
1bc3b0188a
Add new project to Third Party Packages (#1364)
* Add new project to Third Party Packages

* Fix typo

Co-authored-by: Josep Cugat <jcugat@gmail.com>

* Update third-party-packages.md

Co-authored-by: Josep Cugat <jcugat@gmail.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-10-24 23:32:51 +02:00
Florimond Manca
2f54548dad
Drop unecessary host="localhost" in https_server fixture to fix CI build (#1367) 2020-10-24 23:25:31 +02:00
Tom Christie
07229b8dff
Close AsyncClient properly in test_async_next_request (#1361) 2020-10-14 08:38:53 +02:00
Simon Willison
ca5f524943
Add raw_path to scope in ASGITransport (#1357)
* Add raw_path to scope in ASGITransport, closes #1356

* Tweaked test
2020-10-09 16:46:26 +01:00
Tom Christie
92ca4d0cc6
Version 0.16.1 (#1354) 2020-10-08 13:14:15 +01:00
cdeler
72a1f2c759
Replacing pytest-cov by coverage (#1353) 2020-10-08 13:05:30 +01:00
Tom Christie
0123bca335
Force lowercase ASGI headers (#1351)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-10-08 12:04:10 +01:00
cdeler
7fda99fcef
Correctly handle ipv6 addresses as a part of URL (#1349)
* Correctly handle ipv6 addresses as a host

* Fixed typo

* Added an extra rfc reference

* Update tests/models/test_url.py

* Update tests/models/test_url.py
2020-10-08 11:37:13 +03:00
Tom Christie
dbbcf438cd
Version 0.16 (#1347) 2020-10-06 15:29:40 +01:00
Michael K
160e3088cd
Run tests against Python 3.9 stable (#1348)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-10-06 14:57:30 +01:00
Tom Christie
c725387b2d
Preserve header casing (#1338) 2020-10-06 14:57:10 +01:00
Tom Christie
0eed6a3734
Drop .next()/.anext() in favour of response.next_request (#1339)
* Drop response.next()/response.anext() in favour of response.next_request

* Drop NotRedirectResponse
2020-10-06 14:53:07 +01:00
Tom Christie
2a2bbe58a6
Tighten client closed-state behaviour (#1346)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-10-06 13:38:05 +01:00
Michael K
a3eb0f99dc
Run tests against Python 3.9 and add trove classifier (#1342)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-10-06 13:12:52 +01:00
Jair Henrique
4487ac067c
Add VCR.py to third party packages doc. (#1345) 2020-10-05 22:11:52 +02:00
Changsheng
4b8774041d
Allow covariants of __enter__, __aenter__, and @classmethod (#1336)
* Allow covariants of __enter__, __aenter__, and @classmethod

The problem we currently have is the return type of classes such as
Client does not allow covariants when subclassing or context manager.
In other words:

```python
class Base:
    def __enter__(self) -> Base:  # XXX
        return self

class Derived(Base):
    ...

with Derived() as derived:
   # The type of derived is Base but not Derived. It is WRONG
    ...
```

There are three approaches to improve type annotations.
1. Just do not type-annotate and let the type checker infer
   `return self`.
2. Use a generic type with a covariant bound
   `_AsyncClient = TypeVar('_AsyncClient', bound=AsyncClient)`
3. Use a generic type `T = TypeVar('T')` or `Self = TypeVar('Self')`

They have pros and cons.
1. It just works and is not friendly to developers as there is no type
   annotation at the first sight. A developer has to reveal its type via
   a type checker. Aslo, documentation tools that rely on type
   annotations lack the type. I haven't found any python docuementation
   tools that rely on type inference to infer `return self`. There are
   some tools simply check annotations.

2. This approach is correct and has a nice covariant bound that adds
   type safety. It is also nice to documentation tools and _somewhat_
   friendly to developers. Type checkers, pyright that I use, always
   shows the the bounded type '_AsyncClient' rather than the subtype.
   Aslo, it requires more key strokes. Not good, not good.

   It is used by `BaseException.with_traceback`
   See https://github.com/python/typeshed/pull/4298/files

3. This approach always type checks, and I believe it _will_ be the
   official solution in the future. Fun fact, Rust has a Self type
   keyword. It is slightly unfriendly to documentation, but is simple to
   implement and easy to understand for developers. Most importantly,
   type checkers love it.

   See https://github.com/python/mypy/issues/1212

But, we can have 2 and 3 combined:

```python
_Base = typing.TypeVar('_Base', bound=Base)

class Base:
   def __enter__(self: _Base) -> _Base:
      return self

class Derive(Base): ...

with Derived() as derived:
   ...  # type of derived is Derived and it's a subtype of Base
```

* revert back type of of SteamContextManager to Response

* Remove unused type definitions

* Add comment and link to PEP484 for clarification

* Switch to `T = TypeVar("T", covariant=True)`

* fixup! Switch to `T = TypeVar("T", covariant=True)`

* Add back bound=xxx in TypeVar

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-10-02 16:34:57 +01:00
Tom Christie
65b69fabdb
Fix typo in CHANGELOG (#1337) 2020-10-02 13:15:23 +01:00
Tom Christie
c9354282ba
Version 0.15.5 (#1335)
* Version 0.15.5

* Tweak ChangeLog
2020-10-01 13:57:08 +01:00
Tom Christie
3f51392bea
Add response.next_request (#1334)
* Add response.next_request

* Add response.next_request

* Add response.next_request to the docs
2020-10-01 13:52:03 +01:00
Johannes
32d37cfdf1
Small namedtuple refactor (#1329)
Plus order consistency because why not..
2020-09-27 22:15:04 +02:00
Tom Christie
a7a76fbb12
Version 0.15.4 (#1327)
* Version 0.15.4

* Update CHANGELOG

* Update CHANGELOG

* Update CHANGELOG
2020-09-25 12:34:52 +01:00
Musale Martin
815ef94ed9
Support header comparisons with dict or list. (#1326)
* Support header comparisons with dict or list.

* Add check for no headers item

* Fixup testcases affected by headers comparison using dict or list

* Update test_responses.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-09-25 12:28:34 +01:00
Tom Christie
666cbbdfe8
Fix automatic .read() when Response instances are created with content=<str> (#1324) 2020-09-25 11:29:17 +01:00
Tom Christie
320bfe1d0e
Fix warning test case (#1322) 2020-09-24 18:50:30 +02:00
Johannes
ac7704e78c
Remove seed-isort-config (#1321)
As of isort 5 seed-isort-config is no longer needed.

We can get rid of some explicit config too as it's now more clever.
2020-09-24 11:08:07 +01:00
Florimond Manca
24da8d40ff
Release 0.15.3 (#1318) 2020-09-24 11:39:02 +02:00
daa
78afd08e0f
Properly close stream on async response close (#1316) 2020-09-24 09:42:26 +02:00
Tom Christie
8ceb34f486
Version 0.15.2 (#1314)
* Fix response.elapsed

* Version 0.15.2
2020-09-23 11:28:22 +01:00
Tom Christie
befa57c6f9
Fix response.elapsed (#1313) 2020-09-23 11:26:12 +01:00
Tom Christie
d25f2bfeff
Fix stream unsetting auth (#1312)
* Fix ASGITransport path escaping

* Add failing test case for auth with streaming

* Fix .stream setting auth=None
2020-09-23 11:25:54 +01:00
emlazzarin
257b8fab6a
update arg name to max_keepalive_connections (#1309)
The old name `max_keepalive` was removed recently, so this updates the docs.
2020-09-23 10:42:21 +01:00
Tom Christie
27e67b32e9
Version 0.15.1 (#1308)
* Update CHANGELOG.md

* Update __version__.py
2020-09-23 11:12:50 +02:00
Tom Christie
e53f995994
Fix ASGITransport path escaping (#1307) 2020-09-23 09:37:19 +01:00
Tom Christie
c923f1af91
Update docs for 0.15 (#1306) 2020-09-22 11:57:14 +01:00
Tom Christie
a63b038267
Include 0.15.0 release date. (#1305) 2020-09-22 11:51:52 +01:00
Tom Christie
5d11756585
Include curio support in CHANGELOG (#1304) 2020-09-22 11:49:33 +01:00
Tom Christie
f932af9172
Version 0.15.0 (#1301)
* Version 0.15.0

* Update CHANGELOG.md

Co-authored-by: Jamie Hewland <jamie.hewland@hpe.com>

* Escalate deprecations into removals.

* Deprecate overly verbose timeout parameter names

* Fully deprecate max_keepalive in favour of explicit max_keepalive_connections

* Fully deprecate PoolLimits in favour of Limits

* Deprecate instantiating 'Timeout' without fully explicit values

* Include deprecation notes in changelog

* Use httpcore 0.11.x

Co-authored-by: Jamie Hewland <jamie.hewland@hpe.com>
2020-09-22 11:44:28 +01:00
Tom Christie
8e4a8a1c73
Finesse URL properties (#1285)
* url.userinfo should be URL encoded bytes

* Neater copy_with implementation

* Finesse API around URL properties and copy_with

* Docstring for URL, and drop url.authority

* Support url.copy_with(raw_path=...)

* Docstrings on URL methods

* Tweak docstring
2020-09-21 11:35:25 +01:00
Tom Christie
f3c29416f1
Support Response(text=...), Response(html=...), Response(json=...) (#1297)
* Refactor content_streams internally

* Tidy up multipart

* Use ByteStream annotation internally

* Support Response(text=...), Response(html=...), Response(json=...)

* Add tests for Response(text=..., html=..., json=...)
2020-09-21 11:19:19 +01:00
Tom Christie
8ee08afe96
Update _client.py (#1300) 2020-09-18 14:17:03 +01:00
Tom Christie
d8050ed753
Neater Host header logic on redirects (#1299) 2020-09-18 12:00:43 +01:00
Tom Christie
ed27682686
NetRC lookups should use host, not host+port (#1298) 2020-09-18 11:50:13 +01:00
Tom Christie
354c4cac1f
Refactor content streams (#1296)
* Refactor content_streams internally

* Tidy up multipart

* Use ByteStream annotation internally
2020-09-18 10:50:15 +01:00
Tom Christie
fbb21fb1ae
Drop ContentStream (#1295)
* Drop ContentStream
2020-09-18 08:41:09 +01:00
Tom Christie
e1f7791e97
Requests from transport API (#1293)
* Refactoring to support instantiating requests from transport API

* Minor refactoring
2020-09-17 11:59:42 +01:00
Tom Christie
09f94edd93
encode -> encode_request (#1292) 2020-09-17 09:33:36 +01:00
Tom Christie
ff0febbaa9
Update README.md (#1291)
* Update README.md

* Update index.md
2020-09-17 09:11:41 +01:00