Skip to content
Myr

Use ruff instead of flake8, autoflake and isort (#2648)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Use ruff instead of flake8, autoflake and isort * Update pyproject.toml

authored by Marcelo Trylesinski · committed by GitHub · parent ab8177c · Browse files · 11 files+22 added−30 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+22 added−30 removed

  • tests:+9 added−9 removed
  • other:+13 added−21 removed

11 files+22 added−30 removed

modified:httpx/_urls.py+1 added-2 removed
1 unmodified line
2from urllib.parse import parse_qs, unquote34import idna56from ._types import PrimitiveData, QueryParamTypes, RawURL, URLTypes6from ._types import QueryParamTypes, RawURL, URLTypes7from ._urlparse import urlencode, urlparse8from ._utils import primitive_value_to_str910
410 unmodified lines
421 assert not (args and kwargs), "Cannot mix named and unnamed arguments."422423 value = args[0] if args else kwargs424425 items: typing.Sequence[typing.Tuple[str, PrimitiveData]]425 if value is None or isinstance(value, (str, bytes)):426 value = value.decode("ascii") if isinstance(value, bytes) else value427 self._dict = parse_qs(value, keep_blank_values=True)428 elif isinstance(value, QueryParams):
214 unmodified lines
modified:scripts/check+1 added-2 removed
8 unmodified lines
9set -x1011./scripts/sync-version12${PREFIX}black --check --diff --target-version=py37 $SOURCE_FILES13${PREFIX}flake8 $SOURCE_FILES13${PREFIX}mypy $SOURCE_FILES15${PREFIX}isort --check --diff --project=httpx $SOURCE_FILES14${PREFIX}ruff check --diff $SOURCE_FILES
modified:scripts/lint+1 added-2 removed
6 unmodified lines
7export SOURCE_FILES="httpx tests"89set -x1011${PREFIX}autoflake --in-place --recursive $SOURCE_FILES12${PREFIX}isort --project=httpx $SOURCE_FILES11${PREFIX}ruff --fix $SOURCE_FILES12${PREFIX}black --target-version=py37 $SOURCE_FILES
modified:tests/client/test_async_client.py+1 added-1 removed
82 unmodified lines
83 pass8485 assert response.status_code == 20086 with pytest.raises(httpx.ResponseNotRead):87 response.content87 response.content # noqa: B018888990@pytest.mark.anyio91async def test_stream_request(server):
282 unmodified lines
modified:tests/models/test_requests.py+3 added-3 removed
103 unmodified lines
104 yield b""105106 request = httpx.Request("POST", "http://example.org", content=streaming_body())107 with pytest.raises(httpx.RequestNotRead):108 request.content108 request.content # noqa: B018109110111def test_transfer_encoding_header():112 async def streaming_body(data: bytes) -> typing.AsyncIterator[bytes]:
87 unmodified lines
200 data = streaming_body(b"test 123")201 request = httpx.Request("POST", "http://example.org", content=data)202 pickle_request = pickle.loads(pickle.dumps(request))203 with pytest.raises(httpx.RequestNotRead):204 pickle_request.content204 pickle_request.content # noqa: B018205 with pytest.raises(httpx.StreamClosed):206 await pickle_request.aread()207208 request = httpx.Request("POST", "http://example.org", content=data)
8 unmodified lines
217218 request = httpx.Request("POST", "http://example.org", content=content())219 pickle_request = pickle.loads(pickle.dumps(request))220 with pytest.raises(httpx.RequestNotRead):221 pickle_request.content221 pickle_request.content # noqa: B018222 with pytest.raises(httpx.StreamClosed):223 pickle_request.read()224225 request = httpx.Request("POST", "http://example.org", content=content())
3 unmodified lines
modified:tests/models/test_responses.py+3 added-3 removed
746 unmodified lines
747 content=async_streaming_body(),748 )749750 with pytest.raises(RuntimeError):751 response.elapsed751 response.elapsed # noqa: B018752753754def test_unknown_status_code():755 response = httpx.Response(
152 unmodified lines
908def test_cannot_access_unset_request():909 response = httpx.Response(200, content=b"Hello, world!")910911 with pytest.raises(RuntimeError):912 response.request912 response.request # noqa: B018913914915def test_generator_with_transfer_encoding_header():916 def content() -> typing.Iterator[bytes]:
34 unmodified lines
951async def test_response_async_streaming_picklable():952 response = httpx.Response(200, content=async_streaming_body())953 pickle_response = pickle.loads(pickle.dumps(response))954 with pytest.raises(httpx.ResponseNotRead):955 pickle_response.content955 pickle_response.content # noqa: B018956 with pytest.raises(httpx.StreamClosed):957 await pickle_response.aread()958 assert pickle_response.is_stream_consumed is False959 assert pickle_response.num_bytes_downloaded == 0
52 unmodified lines
modified:tests/test_exceptions.py+1 added-1 removed
51 unmodified lines
52def test_request_attribute() -> None:53 # Exception without request attribute54 exc = httpx.ReadTimeout("Read operation timed out")55 with pytest.raises(RuntimeError):56 exc.request56 exc.request # noqa: B0185758 # Exception with request attribute59 request = httpx.Request("GET", "https://www.example.com")60 exc = httpx.ReadTimeout("Read operation timed out", request=request)
1 unmodified line
modified:tests/test_wsgi.py+1 added-1 removed
159 unmodified lines
160 """161 SERVER_PORT is populated correctly from the requested URL.162 """163 hello_world_app = application_factory([b"Hello, World!"])164 server_port: str164 server_port: typing.Optional[str] = None165166 def app(environ, start_response):167 nonlocal server_port168 server_port = environ["SERVER_PORT"]
7 unmodified lines
modified:pyproject.toml+9 added
88 unmodified lines
8990[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]91pattern = 'src="(docs/img/.*?)"'92replacement = 'src="https://raw.githubusercontent.com/encode/httpx/master/\1"'9394# https://beta.ruff.rs/docs/configuration/#using-rufftoml95[tool.ruff]96select = ["E", "F", "I", "B", "PIE"]97ignore = ["B904", "B028"]98line-length = 12099100[tool.ruff.isort]101combine-as-imports = true
modified:requirements.txt+1 added-7 removed
17 unmodified lines
18build==0.10.019twine==4.0.22021# Tests & Linting22autoflake==1.7.722black==23.3.023coverage==7.2.224cryptography==39.0.126flake8==3.9.227flake8-bugbear==23.1.2028flake8-pie==0.16.0; python_version>='3.7'29importlib-metadata==4.13.0; python_version>='3.7'30isort==5.11.4; python_version<'3.8'31isort==5.12.0; python_version>='3.8'25mypy==1.0.126types-certifi==2021.10.8.227pytest==7.2.228ruff==0.0.26029trio==0.22.030trio-typing==0.7.031trustme==0.9.032uvicorn==0.20.0
modified:setup.cfg-8 removed
1[flake8]2ignore = W503, E203, B305, PIE8013max-line-length = 12041[mypy]2ignore_missing_imports = True3strict = True45[mypy-tests.*]6disallow_untyped_defs = False7check_untyped_defs = True813[tool:isort]14profile = black15combine_as_imports = True169[tool:pytest]10addopts = -rxXs11filterwarnings =12 error
10 unmodified lines