Skip to content

Commit

Permalink
Merge branch 'master' into hyperlink-url-212
Browse files Browse the repository at this point in the history
  • Loading branch information
glyph authored Mar 24, 2020
2 parents 380f411 + 9c1741d commit e2f50a6
Show file tree
Hide file tree
Showing 22 changed files with 192 additions and 67 deletions.
44 changes: 44 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
=========
Changelog
=========

.. currentmodule:: treq

.. default-role:: any

.. towncrier release notes start
20.3.0 (2020-03-15)
===================

Features
--------

- Python 3.7 support. (`#228 <https://github.com/twisted/treq/issues/228>`__)


Bugfixes
--------

- `treq.testing.RequestTraversalAgent` now passes its memory reactor to the `twisted.web.server.Site` it creates, preventing the ``Site`` from polluting the global reactor. (`#225 <https://github.com/twisted/treq/issues/225>`__)
- `treq.testing` no longer generates deprecation warnings about ``twisted.test.proto_helpers.MemoryReactor``. (`#253 <https://github.com/twisted/treq/issues/253>`__)


Improved Documentation
----------------------

- The ``download_file.py`` example has been updated to do a streaming download with *unbuffered=True*. (`#233 <https://github.com/twisted/treq/issues/233>`__)
- The *agent* parameter to `treq.request()` has been documented. (`#235 <https://github.com/twisted/treq/issues/235>`__)
- The type of the *headers* element of a response tuple passed to `treq.testing.RequestSequence` is now correctly documented as `str`. (`#237 <https://github.com/twisted/treq/issues/237>`__)


Deprecations and Removals
-------------------------

- Drop support for Python 3.4. (`#240 <https://github.com/twisted/treq/issues/240>`__)


Misc
----

- `#247 <https://github.com/twisted/treq/issues/247>`__, `#248 <https://github.com/twisted/treq/issues/248>`__, `#249 <https://github.com/twisted/treq/issues/249>`__
39 changes: 39 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Developing
==========

Install dependencies:

::

pip install treq[dev]

Run Tests (unit & integration):

::

trial treq

Lint:

::

pep8 treq
pyflakes treq

Build docs::

tox -e docs

Release notes
-------------

We use `towncrier`_ to manage our release notes.
Basically, every pull request that has a user visible effect should add a short file to the `changelog.d/ <./changelog.d>`_ directory describing the change,
with a name like <ISSUE NUMBER>.<TYPE>.rst.
See `changelog.d/README.rst <changelog.d/README.rst>`_ for details.
This way we can keep a good list of changes as we go,
which makes the release manager happy,
which means we get more frequent releases,
which means your change gets into users’ hands faster.

.. _towncrier: https://pypi.org/project/towncrier/
10 changes: 9 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
include README.rst LICENSE tox.ini tox2travis.py .coveragerc
include pyproject.toml
include *.rst
include LICENSE
include .coveragerc
recursive-include docs *
prune docs/_build
prune docs/html

exclude tox.ini
exclude tox2travis.py
exclude .travis.yml
exclude .readthedocs.yml

# This directory will be empty at release time.
prune changelog.d

global-exclude .DS_Store *.pyc *.pyo __pycache__
51 changes: 19 additions & 32 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
treq
====
treq: High-level Twisted HTTP Client API
========================================

|pypi|_
|build|_
|coverage|_

``treq`` is an HTTP library inspired by
`requests <http://www.python-requests.org>`_ but written on top of
`Twisted <http://www.twistedmatrix.com>`_'s
`Agents <http://twistedmatrix.com/documents/current/api/twisted.web.client.Agent.html>`_.
`requests <https://requests.readthedocs.io/>`_ but written on top of
`Twisted <https://www.twistedmatrix.com>`_'s
`Agents <https://twistedmatrix.com/documents/current/api/twisted.web.client.Agent.html>`_.

It provides a simple, higher level API for making HTTP requests when
using Twisted.
Expand All @@ -27,40 +27,27 @@ using Twisted.
>>> reactor.run()
200
For more info `read the docs <http://treq.readthedocs.org>`_.
For more info `read the docs <https://treq.readthedocs.org>`_.

Contribute
==========
Contributing
------------

``treq`` is hosted on `GitHub <http://github.com/twisted/treq>`_.
``treq`` development is hosted on `GitHub <https://github.com/twisted/treq>`_.

Feel free to fork and send contributions over.
We welcome contributions: feel to fork and send contributions over.
See `CONTRIBUTING.rst <https://github.com/twisted/treq/blob/master/CONTRIBUTING.rst>`_ for more info.

Developing
==========
Code of Conduct
---------------

Install dependencies:
Refer to the `Twisted code of conduct <https://github.com/twisted/twisted/blob/trunk/code_of_conduct.md>`_.

::
Copyright and License
---------------------

pip install treq[dev]
``treq`` is made available under the MIT license.
See `LICENSE <./LICENSE>`_ for legal details and copyright notices.

Run Tests (unit & integration):

::

trial treq

Lint:

::

pep8 treq
pyflakes treq

Build docs::

tox -e docs

.. |build| image:: https://api.travis-ci.org/twisted/treq.svg?branch=master
.. _build: https://travis-ci.org/twisted/treq
Expand All @@ -69,4 +56,4 @@ Build docs::
.. _coverage: https://coveralls.io/github/twisted/treq

.. |pypi| image:: https://img.shields.io/pypi/v/treq.svg
.. _pypi: https://pypi.python.org/pypi/treq
.. _pypi: https://pypi.org/project/treq/
27 changes: 27 additions & 0 deletions changelog.d/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This directory collects "newsfragments": short files that each contain
a snippet of ReST-formatted text that will be added to the next
release notes. This should be a description of aspects of the change
(if any) that are relevant to users. (This contrasts with your commit
message and PR description, which are a description of the change as
relevant to people working on the code itself.)

Each file should be named like ``<ISSUE>.<TYPE>.rst``, where
``<ISSUE>`` is an issue numbers, and ``<TYPE>`` is one of:

* ``feature``
* ``bugfix``
* ``doc``
* ``removal``
* ``misc``

So for example: ``123.feature.rst``, ``456.bugfix.rst``

If your PR fixes an issue, use that number here. If there is no issue,
then after you submit the PR and get the PR number you can add a
newsfragment using that instead.

Note that the ``towncrier`` tool will automatically
reflow your text, so don't try to do any fancy formatting. You can
install ``towncrier`` and then run ``towncrier --draft`` if you want
to get a preview of how your change will look in the final release
notes.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../CHANGELOG.rst
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# General information about the project.
project = u'treq'
copyright = u'2014, David Reid'
copyright = u'2014–2020 David Reid'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/basic_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main(reactor, *args):
d = treq.get(
'http://httpbin.org/basic-auth/treq/treq',
'https://httpbin.org/basic-auth/treq/treq',
auth=('treq', 'treq')
)
d.addCallback(print_response)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/basic_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main(reactor, *args):
d = treq.get('http://httpbin.org/get')
d = treq.get('https://httpbin.org/get')
d.addCallback(print_response)
return d

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/basic_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def main(reactor, *args):
d = treq.post('http://httpbin.org/post',
d = treq.post('https://httpbin.org/post',
json.dumps({"msg": "Hello!"}).encode('ascii'),
headers={b'Content-Type': [b'application/json']})
d.addCallback(print_response)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/disable_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main(reactor, *args):
d = treq.get('http://httpbin.org/redirect/1', allow_redirects=False)
d = treq.get('https://httpbin.org/redirect/1', allow_redirects=False)
d.addCallback(print_response)
return d

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/download_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def download_file(reactor, url, destination_filename):
d.addBoth(lambda _: destination.close())
return d

react(download_file, ['http://httpbin.org/get', 'download.txt'])
react(download_file, ['https://httpbin.org/get', 'download.txt'])
10 changes: 5 additions & 5 deletions docs/examples/query_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@
@inlineCallbacks
def main(reactor):
print('List of tuples')
resp = yield treq.get('http://httpbin.org/get',
resp = yield treq.get('https://httpbin.org/get',
params=[('foo', 'bar'), ('baz', 'bax')])
content = yield resp.text()
print(content)

print('Single value dictionary')
resp = yield treq.get('http://httpbin.org/get',
resp = yield treq.get('https://httpbin.org/get',
params={'foo': 'bar', 'baz': 'bax'})
content = yield resp.text()
print(content)

print('Multi value dictionary')
resp = yield treq.get('http://httpbin.org/get',
resp = yield treq.get('https://httpbin.org/get',
params={'foo': ['bar', 'baz', 'bax']})
content = yield resp.text()
print(content)

print('Mixed value dictionary')
resp = yield treq.get('http://httpbin.org/get',
resp = yield treq.get('https://httpbin.org/get',
params={'foo': ['bar', 'baz'], 'bax': 'quux'})
content = yield resp.text()
print(content)

print('Preserved query parameters')
resp = yield treq.get('http://httpbin.org/get?foo=bar',
resp = yield treq.get('https://httpbin.org/get?foo=bar',
params={'baz': 'bax'})
content = yield resp.text()
print(content)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main(reactor, *args):
d = treq.get('http://httpbin.org/redirect/1')
d = treq.get('https://httpbin.org/redirect/1')
d.addCallback(print_response)
return d

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/response_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main(reactor, *args):
d = treq.get('http://httpbin.org/redirect/1')
d = treq.get('https://httpbin.org/redirect/1')

def cb(response):
print('Response history:')
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/using_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


def main(reactor, *args):
d = treq.get('http://httpbin.org/cookies/set?hello=world')
d = treq.get('https://httpbin.org/cookies/set?hello=world')

def _get_jar(resp):
jar = resp.cookies()

print('The server set our hello cookie to: {}'.format(jar['hello']))

return treq.get('http://httpbin.org/cookies', cookies=jar)
return treq.get('https://httpbin.org/cookies', cookies=jar)

d.addCallback(_get_jar)
d.addCallback(print_response)
Expand Down
8 changes: 4 additions & 4 deletions docs/howto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The ``auth`` argument should be a tuple of the form ``('username', 'password')``

.. literalinclude:: examples/basic_auth.py
:linenos:
:lines: 7-13
:lines: 7-15

Full example: :download:`basic_auth.py <examples/basic_auth.py>`

Expand All @@ -63,7 +63,7 @@ The following will print a 200 OK response.

.. literalinclude:: examples/redirects.py
:linenos:
:lines: 7-13
:lines: 7-12

Full example: :download:`redirects.py <examples/redirects.py>`

Expand All @@ -72,7 +72,7 @@ any of the request methods.

.. literalinclude:: examples/disable_redirects.py
:linenos:
:lines: 7-13
:lines: 7-12

Full example: :download:`disable_redirects.py <examples/disable_redirects.py>`

Expand All @@ -94,7 +94,7 @@ via the ``cookies`` keyword argument. Later cookies set by the server can be
retrieved using the :py:meth:`~treq.response._Response.cookies()` method.

The object returned by :py:meth:`~treq.response._Response.cookies()` supports the same key/value
access as `requests cookies <http://requests.readthedocs.org/en/latest/user/quickstart/#cookies>`_.
access as `requests cookies <https://requests.readthedocs.io/en/latest/user/quickstart/#cookies>`_.

.. literalinclude:: examples/using_cookies.py
:linenos:
Expand Down
Loading

0 comments on commit e2f50a6

Please sign in to comment.