From 8b7f9a9b7ecb62ec66ea77b97ed877e063fdf115 Mon Sep 17 00:00:00 2001 From: Giovanni Barillari Date: Wed, 24 Jan 2024 16:02:41 +0100 Subject: [PATCH] Drop `black` in favor of `ruff` --- Makefile | 13 ++++++------- granian/_internal.py | 2 +- granian/server.py | 4 ++-- pyproject.toml | 13 ++++--------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index b7e350ad..ac95ab29 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/granian/_internal.py b/granian/_internal.py index 6ebc300a..36d80773 100644 --- a/granian/_internal.py +++ b/granian/_internal.py @@ -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}'.") diff --git a/granian/server.py b/granian/server.py index 8f198369..72df75e6 100644 --- a/granian/server.py +++ b/granian/server.py @@ -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: diff --git a/pyproject.toml b/pyproject.toml index 6bcbd76c..639f8026 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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', @@ -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 @@ -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'