Skip to content

Commit ebee31f

Browse files
committed
From isort to ruff
1 parent cfb9442 commit ebee31f

28 files changed

Lines changed: 205 additions & 186 deletions

.github/workflows/tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,8 @@ jobs:
7373
- name: Run black (code formatting check)
7474
run: black --check jsweb Tests
7575

76-
- name: Run isort (import sorting check)
77-
run: isort --check-only jsweb Tests
78-
79-
- name: Run flake8 (linting)
80-
run: flake8 jsweb Tests
76+
- name: Run Ruff (lint & import check)
77+
run: ruff check jsweb Tests
8178

8279
- name: Run mypy (type checking)
8380
run: mypy jsweb --ignore-missing-imports --no-error-summary 2>/dev/null || true

Tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Pytest configuration and shared fixtures for jsweb tests."""
22

3+
import sys
34
from io import BytesIO
45
from pathlib import Path
5-
import sys
66

77
import pytest
88

@@ -128,7 +128,7 @@ def file_upload_environ(fake_environ):
128128
f"\r\n"
129129
f"test file content\r\n"
130130
f"--{boundary}--\r\n"
131-
).encode("utf-8")
131+
).encode()
132132

133133
return fake_environ(
134134
method="POST",

Tests/test_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Tests for new JsWeb features (JSON parsing, file uploads, validators)."""
22

3-
from io import BytesIO
43
import json
4+
from io import BytesIO
55

66
import pytest
77

Tests/test_performance.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def handler(req):
8686
def test_starlette_routing_performance():
8787
"""Benchmark Starlette routing performance (if available)."""
8888
try:
89-
from starlette.routing import Route, Router as StarletteRouter
89+
from starlette.routing import Route
90+
from starlette.routing import Router as StarletteRouter
9091
except ImportError:
9192
pytest.skip("Starlette not installed")
9293

Tests/test_request_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Tests for JsWeb request and response handling."""
22

3-
from io import BytesIO
43
import json
4+
from io import BytesIO
55

66
import pytest
77

@@ -376,7 +376,7 @@ def test_response_string_conversion():
376376
from jsweb.response import Response
377377

378378
response = Response("Test content")
379-
response_str = str(response)
379+
_response_str = str(response)
380380

381381
assert response is not None
382382

Tests/test_routing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def test_dynamic_route_performance():
257257
# Add 10 dynamic routes
258258
for i in range(10):
259259
router.add_route(
260-
f"/users/<int:user_id>/posts/<int:post_id>",
260+
"/users/<int:user_id>/posts/<int:post_id>",
261261
lambda req: "OK",
262262
endpoint=f"user_post_{i}",
263263
)

jsweb/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async def _asgi_app_handler(self, scope, receive, send):
9797
response = JSONResponse({"error": str(e)}, status_code=405)
9898
await response(scope, receive, send)
9999
return
100-
except Exception as e:
100+
except Exception:
101101
response = JSONResponse({"error": "Internal Server Error"}, status_code=500)
102102
await response(scope, receive, send)
103103
return

jsweb/blueprints.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable, List, Optional, Tuple
1+
from collections.abc import Callable
22

33

44
class Blueprint:
@@ -13,9 +13,9 @@ class Blueprint:
1313
def __init__(
1414
self,
1515
name: str,
16-
url_prefix: Optional[str] = None,
17-
static_folder: Optional[str] = None,
18-
static_url_path: Optional[str] = None,
16+
url_prefix: str | None = None,
17+
static_folder: str | None = None,
18+
static_url_path: str | None = None,
1919
):
2020
"""
2121
Initializes a new Blueprint.
@@ -32,16 +32,16 @@ def __init__(
3232
"""
3333
self.name = name
3434
self.url_prefix = url_prefix
35-
self.routes: List[Tuple[str, Callable, List[str], str]] = []
35+
self.routes: list[tuple[str, Callable, list[str], str]] = []
3636
self.static_folder = static_folder
3737
self.static_url_path = static_url_path
3838

3939
def add_route(
4040
self,
4141
path: str,
4242
handler: Callable,
43-
methods: Optional[List[str]] = None,
44-
endpoint: Optional[str] = None,
43+
methods: list[str] | None = None,
44+
endpoint: str | None = None,
4545
):
4646
"""
4747
Programmatically adds a route to the blueprint.
@@ -67,8 +67,8 @@ def add_route(
6767
def route(
6868
self,
6969
path: str,
70-
methods: Optional[List[str]] = None,
71-
endpoint: Optional[str] = None,
70+
methods: list[str] | None = None,
71+
endpoint: str | None = None,
7272
) -> Callable:
7373
"""
7474
A decorator to register a view function for a given path within the blueprint.

jsweb/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def create_project(name):
135135
),
136136
}
137137
for src, dest in text_files_to_copy.items():
138-
with open(src, "r", encoding="utf-8") as f_src:
138+
with open(src, encoding="utf-8") as f_src:
139139
content = f_src.read()
140140
with open(dest, "w", encoding="utf-8") as f_dest:
141141
f_dest.write(content)
@@ -596,7 +596,7 @@ def cli():
596596
logger.info(f"💬 Auto-generated message: {message}")
597597

598598
command.revision(alembic_cfg, autogenerate=True, message=message)
599-
logger.info(f"✅ Migration script prepared.")
599+
logger.info("✅ Migration script prepared.")
600600

601601
elif args.subcommand == "upgrade":
602602
command.upgrade(alembic_cfg, "head")

jsweb/docs/auto_validation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
"""
77

88
from functools import wraps
9-
import inspect
10-
from typing import Type, get_type_hints
119

1210
from pydantic import ValidationError as PydanticValidationError
1311

1412

15-
def validate_request_body(dto_class: Type):
13+
def validate_request_body(dto_class: type):
1614
"""
1715
Decorator that automatically validates request body against a DTO.
1816
@@ -84,7 +82,7 @@ async def wrapper(req, *args, **kwargs):
8482
return decorator
8583

8684

87-
def auto_serialize_response(dto_class: Type, status_code: int = 200):
85+
def auto_serialize_response(dto_class: type, status_code: int = 200):
8886
"""
8987
Decorator that automatically serializes DTO responses to JSON.
9088

0 commit comments

Comments
 (0)