Skip to content

Commit

Permalink
Replace Black with ruff formatter (#2150)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminalaee authored Nov 8, 2023
1 parent bf04afb commit 94593f3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ include = ["/uvicorn"]
select = ["E", "F", "I"]
ignore = ["B904", "B028"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
combine-as-imports = true

[tool.mypy]
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ build==1.0.3
twine==4.0.2

# Testing
black==23.7.0
ruff==0.0.286
ruff==0.1.4
pytest==7.4.3
pytest-mock==3.11.1
mypy==1.6.1
Expand Down
2 changes: 1 addition & 1 deletion scripts/check
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export SOURCE_FILES="uvicorn tests"
set -x

./scripts/sync-version
${PREFIX}black --check --diff --target-version=py38 $SOURCE_FILES
${PREFIX}ruff format --check --diff $SOURCE_FILES
${PREFIX}mypy $SOURCE_FILES
${PREFIX}ruff check $SOURCE_FILES
${PREFIX}python -m tools.cli_usage --check
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export SOURCE_FILES="uvicorn tests"

set -x

${PREFIX}black --target-version=py38 $SOURCE_FILES
${PREFIX}ruff format $SOURCE_FILES
${PREFIX}ruff --fix $SOURCE_FILES
${PREFIX}python -m tools.cli_usage
21 changes: 12 additions & 9 deletions tests/protocols/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ def app(scope):
pass # ok, wsproto 0.13
else:
assert response.status_code == 400
assert response.text.lower().strip().rstrip(".") in [
"missing sec-websocket-key header",
"missing sec-websocket-version header", # websockets
"missing or empty sec-websocket-key header", # wsproto
"failed to open a websocket connection: missing "
"sec-websocket-key header",
"failed to open a websocket connection: missing or empty "
"sec-websocket-key header",
]
assert (
response.text.lower().strip().rstrip(".")
in [
"missing sec-websocket-key header",
"missing sec-websocket-version header", # websockets
"missing or empty sec-websocket-key header", # wsproto
"failed to open a websocket connection: missing "
"sec-websocket-key header",
"failed to open a websocket connection: missing or empty "
"sec-websocket-key header",
]
)


@pytest.mark.anyio
Expand Down
7 changes: 3 additions & 4 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ def test_reload_dir_is_set(
app="tests.test_config:asgi_app", reload=True, reload_dirs=[str(app_dir)]
)
assert len(caplog.records) == 1
assert (
caplog.records[-1].message
== f"Will watch for changes in these directories: {[str(app_dir)]}"
)
assert caplog.records[
-1
].message == f"Will watch for changes in these directories: {[str(app_dir)]}"
assert config.reload_dirs == [app_dir]
config = Config(
app="tests.test_config:asgi_app", reload=True, reload_dirs=str(app_dir)
Expand Down

0 comments on commit 94593f3

Please sign in to comment.