Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<a href="https://pypi.org/project/rolo/"><img alt="PyPI Version" src="https://img.shields.io/pypi/v/rolo?color=blue"></a>
<a href="https://coveralls.io/github/localstack/rolo?branch=main"><img src="https://coveralls.io/repos/github/localstack/rolo/badge.svg?branch=main"></a>
<a href="https://img.shields.io/pypi/l/rolo.svg"><img alt="PyPI License" src="https://img.shields.io/pypi/l/rolo.svg"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://github.com/astral-sh/ruff"><img alt="Ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
</p>

Rolo is a flexible framework and library to build HTTP-based server applications beyond microservices and REST APIs.
Expand Down Expand Up @@ -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

Expand Down
24 changes: 12 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ hypercorn = [
"hypercorn"
]
dev = [
"black==23.10.0",
"pytest>=7.0",
"hypercorn",
"pydantic",
Expand All @@ -49,7 +48,7 @@ dev = [
"coveralls>=3.3",
"twisted[tls,http2]>=24",
"httpx[http2]",
"ruff==0.1.0"
"ruff==0.17.0"
]
docs = [
"sphinx",
Expand All @@ -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*",
Expand All @@ -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__.:",
Expand Down
6 changes: 2 additions & 4 deletions rolo/gateway/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand All @@ -85,8 +84,7 @@ class ExceptionHandler(t.Protocol[RC]):

def __call__(
self, chain: "HandlerChain", exception: Exception, context: RC, response: Response
):
...
): ...


def call_safe(
Expand Down
9 changes: 4 additions & 5 deletions rolo/testing/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class ServerInfo(Protocol):
class Server(ServerInfo):
"""the BaseWSGIServer satisfies this protocol."""

def shutdown(self):
...
def shutdown(self): ...


@dataclasses.dataclass
Expand Down Expand Up @@ -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

Expand Down
Loading