diff --git a/Makefile b/Makefile index c7f2e24..0cbb21a 100644 --- a/Makefile +++ b/Makefile @@ -21,10 +21,10 @@ clean: rm -rf *.egg-info/ format: - $(VENV_RUN); python -m ruff check --show-source --fix .; python -m black . + $(VENV_RUN); python -m ruff check --output-format=full --fix .; python -m ruff format . lint: - $(VENV_RUN); python -m ruff check --show-source . && python -m black --check . + $(VENV_RUN); python -m ruff check --output-format=full . && python -m ruff format --check . test: venv $(VENV_RUN); python -m pytest diff --git a/README.md b/README.md index 22a5749..06cfa3e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ PyPI Version PyPI License - Code style: black + Ruff

Rolo is a flexible framework and library to build HTTP-based server applications beyond microservices and REST APIs. @@ -143,8 +143,8 @@ to install the python and other developer requirements into a venv run: ### Format code -We use black and isort as code style tools. -To execute them, run: +We use ruff to lint and format the code. +To run it, execute: make format diff --git a/pyproject.toml b/pyproject.toml index 630b51c..890a8ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ hypercorn = [ "hypercorn" ] dev = [ - "black==23.10.0", "pytest>=7.0", "hypercorn", "pydantic", @@ -49,7 +48,7 @@ dev = [ "coveralls>=3.3", "twisted[tls,http2]>=24", "httpx[http2]", - "ruff==0.1.0" + "ruff==0.17.0" ] docs = [ "sphinx", @@ -63,19 +62,10 @@ source = "vcs" [tool.hatch.build.hooks.vcs] version-file = "rolo/version.py" -[tool.black] -line_length = 100 -include = '((rolo)/.*\.py$|tests/.*\.py$)' -#extend_exclude = '()' - [tool.ruff] # Always generate Python 3.10-compatible code. target-version = "py310" -line-length = 110 -select = ["B", "C", "E", "F", "I", "W", "T", "B9"] -ignore = [ - "E501", # E501 Line too long - handled by black, see https://docs.astral.sh/ruff/faq/#is-ruff-compatible-with-black -] +line-length = 100 exclude = [ ".venv*", "venv*", @@ -86,6 +76,16 @@ exclude = [ ".git", ] +[tool.ruff.lint] +select = ["B", "C", "E", "F", "I", "W", "T", "B9"] +ignore = [ + "E501", # E501 Line too long - handled by the formatter, see https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules +] + +[tool.ruff.format] +# only the library and its tests are formatted +exclude = ["docs/**", "examples/**", "*.md"] + [tool.coverage.report] exclude_lines = [ "if __name__ == .__main__.:", diff --git a/rolo/gateway/chain.py b/rolo/gateway/chain.py index 580ca9b..d87aa69 100644 --- a/rolo/gateway/chain.py +++ b/rolo/gateway/chain.py @@ -75,8 +75,7 @@ class Handler(t.Protocol[RC]): """The signature of request or response handler in the handler chain. Receives the HandlerChain, the RequestContext, and the Response object to be populated.""" - def __call__(self, chain: "HandlerChain", context: RC, response: Response): - ... + def __call__(self, chain: "HandlerChain", context: RC, response: Response): ... class ExceptionHandler(t.Protocol[RC]): @@ -85,8 +84,7 @@ class ExceptionHandler(t.Protocol[RC]): def __call__( self, chain: "HandlerChain", exception: Exception, context: RC, response: Response - ): - ... + ): ... def call_safe( diff --git a/rolo/testing/pytest.py b/rolo/testing/pytest.py index c7d3424..496f089 100644 --- a/rolo/testing/pytest.py +++ b/rolo/testing/pytest.py @@ -35,8 +35,7 @@ class ServerInfo(Protocol): class Server(ServerInfo): """the BaseWSGIServer satisfies this protocol.""" - def shutdown(self): - ... + def shutdown(self): ... @dataclasses.dataclass @@ -210,9 +209,9 @@ def _run(): threading.Thread(target=_run, daemon=True).start() - assert poll_condition( - lambda: reactor.running, timeout=5 - ), f"gave up waiting for {reactor} to start" + assert poll_condition(lambda: reactor.running, timeout=5), ( + f"gave up waiting for {reactor} to start" + ) yield reactor