import idna
-from ._types import PrimitiveData, QueryParamTypes, RawURL, URLTypes
+from ._types import QueryParamTypes, RawURL, URLTypes
from ._urlparse import urlencode, urlparse
from ._utils import primitive_value_to_str
value = args[0] if args else kwargs
- items: typing.Sequence[typing.Tuple[str, PrimitiveData]]
if value is None or isinstance(value, (str, bytes)):
value = value.decode("ascii") if isinstance(value, bytes) else value
self._dict = parse_qs(value, keep_blank_values=True)
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
pattern = 'src="(docs/img/.*?)"'
replacement = 'src="https://raw.githubusercontent.com/encode/httpx/master/\1"'
+
+# https://beta.ruff.rs/docs/configuration/#using-rufftoml
+[tool.ruff]
+select = ["E", "F", "I", "B", "PIE"]
+ignore = ["B904", "B028"]
+line-length = 120
+
+[tool.ruff.isort]
+combine-as-imports = true
twine==4.0.2
# Tests & Linting
-autoflake==1.7.7
black==23.3.0
coverage==7.2.2
cryptography==39.0.1
-flake8==3.9.2
-flake8-bugbear==23.1.20
-flake8-pie==0.16.0; python_version>='3.7'
-importlib-metadata==4.13.0; python_version>='3.7'
-isort==5.11.4; python_version<'3.8'
-isort==5.12.0; python_version>='3.8'
mypy==1.0.1
types-certifi==2021.10.8.2
pytest==7.2.2
+ruff==0.0.260
trio==0.22.0
trio-typing==0.7.0
trustme==0.9.0
./scripts/sync-version
${PREFIX}black --check --diff --target-version=py37 $SOURCE_FILES
-${PREFIX}flake8 $SOURCE_FILES
${PREFIX}mypy $SOURCE_FILES
-${PREFIX}isort --check --diff --project=httpx $SOURCE_FILES
+${PREFIX}ruff check --diff $SOURCE_FILES
set -x
-${PREFIX}autoflake --in-place --recursive $SOURCE_FILES
-${PREFIX}isort --project=httpx $SOURCE_FILES
+${PREFIX}ruff --fix $SOURCE_FILES
${PREFIX}black --target-version=py37 $SOURCE_FILES
-[flake8]
-ignore = W503, E203, B305, PIE801
-max-line-length = 120
-
[mypy]
ignore_missing_imports = True
strict = True
disallow_untyped_defs = False
check_untyped_defs = True
-[tool:isort]
-profile = black
-combine_as_imports = True
-
[tool:pytest]
addopts = -rxXs
filterwarnings =
assert response.status_code == 200
with pytest.raises(httpx.ResponseNotRead):
- response.content
+ response.content # noqa: B018
@pytest.mark.anyio
request = httpx.Request("POST", "http://example.org", content=streaming_body())
with pytest.raises(httpx.RequestNotRead):
- request.content
+ request.content # noqa: B018
def test_transfer_encoding_header():
request = httpx.Request("POST", "http://example.org", content=data)
pickle_request = pickle.loads(pickle.dumps(request))
with pytest.raises(httpx.RequestNotRead):
- pickle_request.content
+ pickle_request.content # noqa: B018
with pytest.raises(httpx.StreamClosed):
await pickle_request.aread()
request = httpx.Request("POST", "http://example.org", content=content())
pickle_request = pickle.loads(pickle.dumps(request))
with pytest.raises(httpx.RequestNotRead):
- pickle_request.content
+ pickle_request.content # noqa: B018
with pytest.raises(httpx.StreamClosed):
pickle_request.read()
)
with pytest.raises(RuntimeError):
- response.elapsed
+ response.elapsed # noqa: B018
def test_unknown_status_code():
response = httpx.Response(200, content=b"Hello, world!")
with pytest.raises(RuntimeError):
- response.request
+ response.request # noqa: B018
def test_generator_with_transfer_encoding_header():
response = httpx.Response(200, content=async_streaming_body())
pickle_response = pickle.loads(pickle.dumps(response))
with pytest.raises(httpx.ResponseNotRead):
- pickle_response.content
+ pickle_response.content # noqa: B018
with pytest.raises(httpx.StreamClosed):
await pickle_response.aread()
assert pickle_response.is_stream_consumed is False
# Exception without request attribute
exc = httpx.ReadTimeout("Read operation timed out")
with pytest.raises(RuntimeError):
- exc.request
+ exc.request # noqa: B018
# Exception with request attribute
request = httpx.Request("GET", "https://www.example.com")
SERVER_PORT is populated correctly from the requested URL.
"""
hello_world_app = application_factory([b"Hello, World!"])
- server_port: str
+ server_port: typing.Optional[str] = None
def app(environ, start_response):
nonlocal server_port