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
Provenance
- Commit
daec2bd- Tree
ed631d7- Author
Marcelo Trylesinski <marcelotryle@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
ab8177c
11 files changed+22 added−30 removed
modified:httpx/_urls.py+1 added-2 removed
1 unmodified line2 from urllib.parse import parse_qs, unquote3 4 import idna5 6-from ._types import PrimitiveData, QueryParamTypes, RawURL, URLTypes6+from ._types import QueryParamTypes, RawURL, URLTypes7 from ._urlparse import urlencode, urlparse8 from ._utils import primitive_value_to_str9 10 410 unmodified lines421 assert not (args and kwargs), "Cannot mix named and unnamed arguments."422 423 value = args[0] if args else kwargs424 425- 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 linesmodified:scripts/check+1 added-2 removed
8 unmodified lines9 set -x10 11 ./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_FILESmodified:scripts/lint+1 added-2 removed
6 unmodified lines7 export SOURCE_FILES="httpx tests"8 9 set -x10 11-${PREFIX}autoflake --in-place --recursive $SOURCE_FILES12-${PREFIX}isort --project=httpx $SOURCE_FILES11+${PREFIX}ruff --fix $SOURCE_FILES12 ${PREFIX}black --target-version=py37 $SOURCE_FILESmodified:tests/client/test_async_client.py+1 added-1 removed
82 unmodified lines83 pass84 85 assert response.status_code == 20086 with pytest.raises(httpx.ResponseNotRead):87- response.content87+ response.content # noqa: B01888 89 90 @pytest.mark.anyio91 async def test_stream_request(server):282 unmodified linesmodified:tests/models/test_requests.py+3 added-3 removed
103 unmodified lines104 yield b""105 106 request = httpx.Request("POST", "http://example.org", content=streaming_body())107 with pytest.raises(httpx.RequestNotRead):108- request.content108+ request.content # noqa: B018109 110 111 def test_transfer_encoding_header():112 async def streaming_body(data: bytes) -> typing.AsyncIterator[bytes]:87 unmodified lines200 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()207 208 request = httpx.Request("POST", "http://example.org", content=data)8 unmodified lines217 218 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()224 225 request = httpx.Request("POST", "http://example.org", content=content())3 unmodified linesmodified:tests/models/test_responses.py+3 added-3 removed
746 unmodified lines747 content=async_streaming_body(),748 )749 750 with pytest.raises(RuntimeError):751- response.elapsed751+ response.elapsed # noqa: B018752 753 754 def test_unknown_status_code():755 response = httpx.Response(152 unmodified lines908 def test_cannot_access_unset_request():909 response = httpx.Response(200, content=b"Hello, world!")910 911 with pytest.raises(RuntimeError):912- response.request912+ response.request # noqa: B018913 914 915 def test_generator_with_transfer_encoding_header():916 def content() -> typing.Iterator[bytes]:34 unmodified lines951 async 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 == 052 unmodified linesmodified:tests/test_exceptions.py+1 added-1 removed
51 unmodified lines52 def 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: B01857 58 # Exception with request attribute59 request = httpx.Request("GET", "https://www.example.com")60 exc = httpx.ReadTimeout("Read operation timed out", request=request)1 unmodified linemodified:tests/test_wsgi.py+1 added-1 removed
159 unmodified lines160 """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] = None165 166 def app(environ, start_response):167 nonlocal server_port168 server_port = environ["SERVER_PORT"]7 unmodified linesmodified:pyproject.toml+9 added
88 unmodified lines89 90 [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]91 pattern = 'src="(docs/img/.*?)"'92 replacement = 'src="https://raw.githubusercontent.com/encode/httpx/master/\1"'93+94+# https://beta.ruff.rs/docs/configuration/#using-rufftoml95+[tool.ruff]96+select = ["E", "F", "I", "B", "PIE"]97+ignore = ["B904", "B028"]98+line-length = 12099+100+[tool.ruff.isort]101+combine-as-imports = truemodified:requirements.txt+1 added-7 removed
17 unmodified lines18 build==0.10.019 twine==4.0.220 21 # Tests & Linting22-autoflake==1.7.722 black==23.3.023 coverage==7.2.224 cryptography==39.0.126-flake8==3.9.227-flake8-bugbear==23.1.2028-flake8-pie==0.16.0; python_version>='3.7'29-importlib-metadata==4.13.0; python_version>='3.7'30-isort==5.11.4; python_version<'3.8'31-isort==5.12.0; python_version>='3.8'25 mypy==1.0.126 types-certifi==2021.10.8.227 pytest==7.2.228+ruff==0.0.26029 trio==0.22.030 trio-typing==0.7.031 trustme==0.9.032 uvicorn==0.20.0modified:setup.cfg-8 removed
1-[flake8]2-ignore = W503, E203, B305, PIE8013-max-line-length = 1204-1 [mypy]2 ignore_missing_imports = True3 strict = True4 5 [mypy-tests.*]6 disallow_untyped_defs = False7 check_untyped_defs = True8 13-[tool:isort]14-profile = black15-combine_as_imports = True16-9 [tool:pytest]10 addopts = -rxXs11 filterwarnings =12 error10 unmodified lines