Skip to content

Commit 40f1ec1

Browse files
authored
fix: format, lint, and fix test (#215)
1 parent 479f47d commit 40f1ec1

File tree

121 files changed

+311
-210
lines changed

Some content is hidden

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

121 files changed

+311
-210
lines changed

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,11 @@ uv run ruff check
590590

591591
# Type checking
592592
uv run mypy src/
593+
uv run pyright src/
593594
```
594595

596+
TODO: migrate to basedpyright. Try it with `uvx run basedpyright src/`
597+
595598
### Release
596599

597600
```bash
@@ -638,20 +641,14 @@ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENS
638641
To run all tests with coverage reporting:
639642

640643
```bash
641-
uv run scripts/run_tests.sh
644+
uv run pytest --cov=src/surrealdb --cov-report=term-missing --cov-report=html
642645
```
643646

644647
This will:
645648
- Run all tests using pytest
646649
- Show a coverage summary in the terminal
647650
- Generate an HTML coverage report in the `htmlcov/` directory
648651

649-
You can also run tests directly with:
650-
651-
```bash
652-
uv run pytest --cov=src/surrealdb --cov-report=term-missing --cov-report=html
653-
```
654-
655652
To test a specific file:
656653

657654
```bash

examples/django/api/urls.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""API URL configuration."""
22

3-
from django.urls import path, include
3+
from django.urls import include, path
44
from rest_framework.routers import DefaultRouter
5-
from .views import UserViewSet, signup, signin, logout
5+
6+
from .views import UserViewSet, logout, signin, signup
67

78
router = DefaultRouter()
89
router.register(r"users", UserViewSet, basename="user")

examples/django/api/views.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"""API views using Django REST Framework."""
22

3-
from rest_framework import viewsets, status
3+
import logging
4+
5+
from rest_framework import status, viewsets
46
from rest_framework.decorators import api_view
57
from rest_framework.response import Response
6-
import logging
7-
from database import get_connection, close_connection
8-
from .serializers import UserSerializer, SignupSerializer, SigninSerializer
8+
9+
from database import close_connection, get_connection
10+
11+
from .serializers import SigninSerializer, SignupSerializer, UserSerializer
912

1013

1114
class UserViewSet(viewsets.ViewSet):
@@ -100,7 +103,7 @@ async def signup(request):
100103
{"token": token, "message": "User registered successfully"},
101104
status=status.HTTP_201_CREATED,
102105
)
103-
except Exception as e:
106+
except Exception:
104107
logging.exception("Exception during signup")
105108
return Response(
106109
{"error": "An internal error occurred. Please try again later."},
@@ -122,7 +125,7 @@ async def signin(request):
122125
token = await db.signin(serializer.validated_data)
123126
return Response({"token": token, "message": "Signed in successfully"})
124127
logging.exception("Exception during signin")
125-
except Exception as e:
128+
except Exception:
126129
return Response(
127130
{"error": "Invalid credentials or unexpected error."},
128131
status=status.HTTP_401_UNAUTHORIZED,

examples/django/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Configuration for SurrealDB."""
22

33
import os
4+
45
from dotenv import load_dotenv
56

67
load_dotenv()

examples/django/database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Database connection helpers."""
22

33
from surrealdb import AsyncSurreal
4+
45
from config import settings
56

67

examples/django/surrealdb_example/asgi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""ASGI config for surrealdb_example project."""
22

33
import os
4+
45
from django.core.asgi import get_asgi_application
56

67
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "surrealdb_example.settings")

examples/django/surrealdb_example/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
from pathlib import Path
5+
56
from dotenv import load_dotenv
67

78
load_dotenv()

examples/django/surrealdb_example/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""URL configuration for surrealdb_example project."""
22

33
from django.contrib import admin
4-
from django.urls import path, include
54
from django.http import JsonResponse
5+
from django.urls import include, path
66

77

88
async def health(request):

examples/django/surrealdb_example/wsgi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""WSGI config for surrealdb_example project."""
22

33
import os
4+
45
from django.core.wsgi import get_wsgi_application
56

67
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "surrealdb_example.settings")

examples/fastapi/database.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Database connection management."""
22

3-
from typing import AsyncGenerator
43
from contextlib import asynccontextmanager
4+
from typing import AsyncGenerator
5+
56
from surrealdb import AsyncSurreal
7+
68
from config import settings
79

810

0 commit comments

Comments
 (0)