Skip to content

Commit ffe8374

Browse files
authored
Replace black and isort with ruff (#278)
Closes #277
1 parent 9a1fe9f commit ffe8374

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+103
-50
lines changed

.github/workflows/code-quality.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
python-version: 3.8
1212
- run: pip install --upgrade pip
1313
- run: pip install types-setuptools "black<23" ruff "mypy<2" "jsonschema<5" pytest "returns<1" "aiohttp<4" "aiozmq<1" "django<5" "fastapi<1" "flask<3" "flask-socketio<5.3.1" "pyzmq" "sanic" "tornado<7" "uvicorn<1" "websockets<11"
14-
- run: black --diff --check $(git ls-files -- '*.py' ':!:docs/*')
15-
- run: ruff $(git ls-files -- '*.py' ':!:docs/*')
14+
- run: ruff check --select I $(git ls-files -- '*.py' ':!:docs/*')
15+
- run: ruff format --check $(git ls-files -- '*.py' ':!:docs/*')
1616
- run: mypy --strict $(git ls-files -- '*.py' ':!:docs/*')

.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ default_language_version:
33
exclude: (^docs)
44
fail_fast: true
55
repos:
6-
- repo: https://github.com/ambv/black
7-
rev: 22.8.0
8-
hooks:
9-
- id: black
10-
args: [--diff, --check]
11-
12-
- repo: https://github.com/charliermarsh/ruff-pre-commit
13-
rev: v0.0.265
6+
- repo: https://github.com/astral-sh/ruff-pre-commit
7+
rev: v0.4.1
148
hooks:
159
- id: ruff
10+
name: lint with ruff
11+
- id: ruff
12+
name: sort imports with ruff
13+
args: [--select, I, --fix]
14+
- id: ruff-format
15+
name: format with ruff
1616

1717
- repo: https://github.com/pre-commit/mirrors-mypy
1818
rev: v1.2.0

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This file only contains a selection of the most common options. For a full
44
# list see the documentation:
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
from typing import List
67

78
# -- Path setup --------------------------------------------------------------
89

@@ -38,7 +39,7 @@
3839
# List of patterns, relative to source directory, that match files and
3940
# directories to ignore when looking for source files.
4041
# This pattern also affects html_static_path and html_extra_path.
41-
exclude_patterns = []
42+
exclude_patterns: List[str] = []
4243

4344

4445
# -- Options for HTML output -------------------------------------------------

examples/aiohttp_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""AioHTTP server"""
2+
23
from aiohttp import web
3-
from jsonrpcserver import async_dispatch, async_method, Ok, Result
4+
5+
from jsonrpcserver import Ok, Result, async_dispatch, async_method
46

57

68
@async_method

examples/aiozmq_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""AioZMQ server"""
2+
23
import asyncio
34

45
import aiozmq # type: ignore
56
import zmq
6-
from jsonrpcserver import async_dispatch, async_method, Ok, Result
7+
8+
from jsonrpcserver import Ok, Result, async_dispatch, async_method
79

810

911
@async_method

examples/asyncio_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Demonstrates processing a batch of 100 requests asynchronously with asyncio."""
2+
23
import asyncio
34
import json
45

5-
from jsonrpcserver import async_dispatch, async_method, Ok, Result
6+
from jsonrpcserver import Ok, Result, async_dispatch, async_method
67

78

89
@async_method

examples/django_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Django server"""
2+
23
from django.http import HttpRequest, HttpResponse # type: ignore
34
from django.views.decorators.csrf import csrf_exempt # type: ignore
4-
from jsonrpcserver import dispatch, method, Ok, Result
5+
6+
from jsonrpcserver import Ok, Result, dispatch, method
57

68

79
@method

examples/fastapi_server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""FastAPI server"""
2-
from fastapi import FastAPI, Request, Response
2+
33
import uvicorn
4-
from jsonrpcserver import dispatch, method, Ok, Result
4+
from fastapi import FastAPI, Request, Response
5+
6+
from jsonrpcserver import Ok, Result, dispatch, method
57

68
app = FastAPI()
79

examples/flask_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Flask server"""
2+
23
from flask import Flask, Response, request
3-
from jsonrpcserver import dispatch, method, Ok, Result
4+
5+
from jsonrpcserver import Ok, Result, dispatch, method
46

57
app = Flask(__name__)
68

examples/http_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
33
Demonstrates using Python's builtin http.server module to serve JSON-RPC.
44
"""
5+
56
from http.server import BaseHTTPRequestHandler, HTTPServer
67

7-
from jsonrpcserver import dispatch, method, Ok, Result
8+
from jsonrpcserver import Ok, Result, dispatch, method
89

910

1011
@method

0 commit comments

Comments
 (0)