From: Stephen Brown II Date: Tue, 1 Oct 2019 17:02:29 +0000 (-0600) Subject: Add flake8-pie plugin (#419) X-Git-Tag: 0.7.5~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db3e3a0231538cfd4ebcec8a93906c05fc5b68a3;p=thirdparty%2Fhttpx.git Add flake8-pie plugin (#419) --- diff --git a/httpx/client.py b/httpx/client.py index d15d2c16..bfee2de5 100644 --- a/httpx/client.py +++ b/httpx/client.py @@ -325,7 +325,7 @@ class BaseClient: headers = self.merge_headers(headers) cookies = self.merge_cookies(cookies) params = self.merge_queryparams(params) - request = AsyncRequest( + return AsyncRequest( method, url, data=data, @@ -335,7 +335,6 @@ class BaseClient: headers=headers, cookies=cookies, ) - return request class AsyncClient(BaseClient): @@ -718,7 +717,7 @@ class Client(BaseClient): headers=headers, cookies=cookies, ) - response = self.send( + return self.send( request, stream=stream, auth=auth, @@ -728,7 +727,6 @@ class Client(BaseClient): timeout=timeout, trust_env=trust_env, ) - return response def send( self, diff --git a/noxfile.py b/noxfile.py index c7ada4fb..747e30ef 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,7 +20,13 @@ def lint(session): @nox.session(reuse_venv=True) def check(session): session.install( - "black", "flake8", "flake8-bugbear", "flake8-comprehensions", "isort", "mypy" + "black", + "flake8", + "flake8-bugbear", + "flake8-comprehensions", + "flake8-pie", + "isort", + "mypy", ) session.run("black", "--check", "--diff", "--target-version=py36", *source_files) diff --git a/test-requirements.txt b/test-requirements.txt index fb176cab..be06182e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,6 +7,7 @@ cryptography flake8 flake8-bugbear flake8-comprehensions +flake8-pie isort mypy pytest diff --git a/tests/dispatch/test_proxy_http.py b/tests/dispatch/test_proxy_http.py index 2d938715..4776a8d2 100644 --- a/tests/dispatch/test_proxy_http.py +++ b/tests/dispatch/test_proxy_http.py @@ -26,7 +26,7 @@ async def test_proxy_tunnel_success(backend): backend=raw_io, proxy_mode=httpx.HTTPProxyMode.TUNNEL_ONLY, ) as proxy: - response = await proxy.request("GET", f"http://example.com") + response = await proxy.request("GET", "http://example.com") assert response.status_code == 404 assert response.headers["Server"] == "origin-server" @@ -64,7 +64,7 @@ async def test_proxy_tunnel_non_2xx_response(backend, status_code): backend=raw_io, proxy_mode=httpx.HTTPProxyMode.TUNNEL_ONLY, ) as proxy: - await proxy.request("GET", f"http://example.com") + await proxy.request("GET", "http://example.com") # ProxyError.request should be the CONNECT request not the original request assert e.value.request.method == "CONNECT" @@ -116,7 +116,7 @@ async def test_proxy_tunnel_start_tls(backend): backend=raw_io, proxy_mode=httpx.HTTPProxyMode.TUNNEL_ONLY, ) as proxy: - resp = await proxy.request("GET", f"https://example.com") + resp = await proxy.request("GET", "https://example.com") assert resp.status_code == 404 assert resp.headers["Server"] == "origin-server" @@ -128,7 +128,7 @@ async def test_proxy_tunnel_start_tls(backend): await resp.read() # Make another request to see that the tunnel is re-used. - resp = await proxy.request("GET", f"https://example.com/target") + resp = await proxy.request("GET", "https://example.com/target") assert resp.status_code == 200 assert resp.headers["Server"] == "origin-server" @@ -172,7 +172,7 @@ async def test_proxy_forwarding(backend, proxy_mode): proxy_headers={"Proxy-Authorization": "test", "Override": "2"}, ) as proxy: response = await proxy.request( - "GET", f"http://example.com", headers={"override": "1"} + "GET", "http://example.com", headers={"override": "1"} ) assert response.status_code == 200