Skip to content

Commit 04416df

Browse files
committed
feat: ruff fix
1 parent 92c4856 commit 04416df

13 files changed

Lines changed: 33 additions & 37 deletions

File tree

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
from pathlib import Path
22

3-
from config.database import DatabaseConfig
4-
from config.logging import LoggingConfig
5-
from providers.console_provider import ConsoleProvider
6-
from providers.fastapi_provider import FastAPIServiceProvider
7-
8-
from config.app import AppConfig
9-
10-
print("Loading Application class...")
113
from fastapi_startkit.application import Application
124
from fastapi_startkit.exceptions import ExceptionHandler
135
from fastapi_startkit.logging.providers import LogProvider
146
from fastapi_startkit.masoniteorm.providers import DatabaseProvider
157

16-
17-
class _FallbackHandler:
18-
async def render(self, request, exc):
19-
from fastapi.responses import JSONResponse
20-
return JSONResponse(status_code=500, content={"detail": "Internal Server Error"})
8+
from config.app import AppConfig
9+
from config.database import DatabaseConfig
10+
from config.logging import LoggingConfig
11+
from providers.console_provider import ConsoleProvider
12+
from providers.fastapi_provider import FastAPIServiceProvider
2113

2214

2315
class AppExceptionHandler(ExceptionHandler):
2416
def register(self):
25-
self.register_handler(Exception, _FallbackHandler())
26-
17+
pass
2718

2819
app: Application[AppConfig] = Application(
29-
base_path=str(Path().cwd()),
20+
base_path=Path(__file__).parent.parent,
3021
config=AppConfig,
3122
providers=[
3223
(LogProvider, LoggingConfig),
@@ -35,4 +26,4 @@ def register(self):
3526
FastAPIServiceProvider,
3627
],
3728
exception_handler=AppExceptionHandler,
38-
)
29+
)

example/database-app/routes/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
public = Router()
77

88
public.post("/register/student", student_auth.register)
9-
public.post("/register/teacher", AuthController.register_teacher)
9+
public.post("/register/teacher", AuthController.register_teacher)

fastapi_startkit/pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ dev = [
5050
]
5151

5252

53+
[tool.ruff]
54+
line-length = 120
55+
56+
[tool.ruff.lint]
57+
select = ["F401"]
58+
fixable = ["F401"]
59+
5360
[tool.pytest.ini_options]
5461
asyncio_mode = "auto"
5562

fastapi_startkit/src/fastapi_startkit/application.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class Application(Container, Generic[TConfig]):
3030
]
3131

3232
def __init__(
33-
self,
34-
base_path: str | Path = None,
35-
env=None,
36-
providers=None,
37-
config: Type[TConfig] | None = None,
38-
exception_handler: Type[ExceptionHandler] | None = None,
33+
self,
34+
base_path: str | Path = None,
35+
env=None,
36+
providers=None,
37+
config: Type[TConfig] | None = None,
38+
exception_handler: Type[ExceptionHandler] | None = None,
3939
):
4040
super().__init__()
4141

@@ -154,7 +154,7 @@ def mount(self, path: str, app_instance: "FastAPI", **kwargs):
154154

155155
# Add custom exception handlers
156156
def add_exception_handler(
157-
self, exc_class_or_status_code: Any, handler: Callable[..., Any]
157+
self, exc_class_or_status_code: Any, handler: Callable[..., Any]
158158
):
159159
self._fastapi.add_exception_handler(exc_class_or_status_code, handler)
160160
return self
@@ -181,9 +181,9 @@ def load_environment(self):
181181

182182
def is_debug(self) -> bool:
183183
return (
184-
hasattr(self, "_config_instance")
185-
and self._config_instance is not None
186-
and getattr(self._config_instance, "debug", False)
184+
hasattr(self, "_config_instance")
185+
and self._config_instance is not None
186+
and getattr(self._config_instance, "debug", False)
187187
)
188188

189189
def configure_config(self):

fastapi_startkit/src/fastapi_startkit/exceptions/handler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import atexit
33
from typing import Any, Callable, Dict, List, Optional, Type
44

5-
from dumpdie import dd
65

76

87
class ExceptionHandler:

fastapi_startkit/src/fastapi_startkit/fastapi/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class HTTPExceptionHandler:
22
"""
33
The base exception handler for FastAPI applications.
44
"""
5+
56
async def render(self, request, exc):
67
import traceback
78
from fastapi.responses import JSONResponse

fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class MigrateFreshCommand(Command):
2222
description="The location of the migration directory",
2323
),
2424
option(
25-
"no-fk", None, flag=True, description="Re-enable foreign key constraints during drop"
25+
"no-fk",
26+
None,
27+
flag=True,
28+
description="Re-enable foreign key constraints during drop",
2629
),
2730
option(
2831
"seed",

fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from dumpdie import dd
21
from typing import TYPE_CHECKING
32

43
if TYPE_CHECKING:
@@ -14,7 +13,7 @@ def __init__(self, factory: "ConnectionFactory", config: dict):
1413
def connection(self, name: str | None):
1514
name = self.get_default_connection_name(name)
1615
assert name is not None
17-
config = self.config.get('connections', {}).get(name)
16+
config = self.config.get("connections", {}).get(name)
1817

1918
if config is None:
2019
raise ValueError(f"Connection '{name}' not found in configuration")

fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/mysql_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ def get_default_platform(cls):
1717

1818
@classmethod
1919
def get_post_processor(cls):
20-
return MySQLPostProcessor
20+
return MySQLPostProcessor

fastapi_startkit/src/fastapi_startkit/masoniteorm/providers/DatabaseProvider.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from dumpdie import dd
21
from pathlib import Path
32

43
from fastapi_startkit.masoniteorm.commands import (

0 commit comments

Comments
 (0)