Skip to content

Commit

Permalink
Drop black in favor of ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Jan 24, 2024
1 parent 18dc258 commit 8b7f9a9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
.DEFAULT_GOAL := all
black = black granian tests
ruff = ruff granian tests
pysources = granian tests

.PHONY: build-dev
build-dev:
@rm -f granian/*.so
maturin develop --extras test
maturin develop --extras lint,test

.PHONY: format
format:
$(black)
$(ruff) --fix --exit-zero
ruff --fix $(pysources)
ruff format $(pysources)
cargo fmt

.PHONY: lint-python
lint-python:
$(ruff)
$(black) --check --diff
ruff $(pysources)
ruff format --check $(pysources)

.PHONY: lint-rust
lint-rust:
Expand Down
2 changes: 1 addition & 1 deletion granian/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def load_module(module_name: str, raise_on_failure: bool = True) -> Optional[Mod
except ImportError:
if sys.exc_info()[-1].tb_next:
raise RuntimeError(
f"While importing '{module_name}', an ImportError was raised:" f"\n\n{traceback.format_exc()}"
f"While importing '{module_name}', an ImportError was raised:" f'\n\n{traceback.format_exc()}'
)
elif raise_on_failure:
raise RuntimeError(f"Could not import '{module_name}'.")
Expand Down
4 changes: 2 additions & 2 deletions granian/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ def serve(
if sys.platform == 'win32' and self.workers > 1:
self.workers = 1
logger.warn(
"Due to a bug in Windows unblocking socket implementation "
'Due to a bug in Windows unblocking socket implementation '
"granian can't support multiple workers on this platform. "
"Number of workers will now fallback to 1."
'Number of workers will now fallback to 1.'
)

if self.websockets:
Expand Down
13 changes: 4 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ dependencies = [

[project.optional-dependencies]
lint = [
'black~=23.9.0',
'ruff~=0.0.292',
'ruff~=0.1.0',
]
test = [
'httpx~=0.25.0',
Expand Down Expand Up @@ -92,6 +91,9 @@ extend-ignore = [
flake8-quotes = { inline-quotes = 'single', multiline-quotes = 'double' }
mccabe = { max-complexity = 13 }

[tool.ruff.format]
quote-style = 'single'

[tool.ruff.isort]
combine-as-imports = true
lines-after-imports = 2
Expand All @@ -101,12 +103,5 @@ known-first-party = ['granian', 'tests']
'granian/_granian.pyi' = ['I001']
'tests/**' = ['B018', 'S110', 'S501']

[tool.black]
color = true
line-length = 120
target-version = ['py38', 'py39', 'py310', 'py311', 'py312']
skip-string-normalization = true # leave this to ruff
skip-magic-trailing-comma = true # leave this to ruff

[tool.pytest.ini_options]
asyncio_mode = 'auto'

0 comments on commit 8b7f9a9

Please sign in to comment.