mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-05 23:43:11 -05:00
chore: mypy, ruff, extract, openapi, and recipes-scraper updates (#1968)
* bump ruff and mypy * mypy fixes * bump and fix openapi * drop debug statement * bump extruct * bump recipes-scrapers
This commit is contained in:
@@ -36,7 +36,7 @@ def controller(router: APIRouter, *urls: str) -> Callable[[type[T]], type[T]]:
|
||||
return decorator
|
||||
|
||||
|
||||
def _cbv(router: APIRouter, cls: type[T], *urls: str, instance: Any = None) -> type[T]:
|
||||
def _cbv(router: APIRouter, cls: type[T], *urls: str, instance: Any | None = None) -> type[T]:
|
||||
"""
|
||||
Replaces any methods of the provided class `cls` that are endpoints of routes in `router` with updated
|
||||
function calls that will properly inject an instance of `cls`.
|
||||
@@ -46,7 +46,7 @@ def _cbv(router: APIRouter, cls: type[T], *urls: str, instance: Any = None) -> t
|
||||
return cls
|
||||
|
||||
|
||||
def _init_cbv(cls: type[Any], instance: Any = None) -> None:
|
||||
def _init_cbv(cls: type[Any], instance: Any | None = None) -> None:
|
||||
"""
|
||||
Idempotently modifies the provided `cls`, performing the following modifications:
|
||||
* The `__init__` function is updated to set any class-annotated dependencies as instance attributes
|
||||
|
||||
@@ -34,8 +34,8 @@ class HttpRepo(Generic[C, R, U]):
|
||||
self,
|
||||
repo: RepositoryGeneric,
|
||||
logger: Logger,
|
||||
exception_msgs: Callable[[type[Exception]], str] = None,
|
||||
default_message: str = None,
|
||||
exception_msgs: Callable[[type[Exception]], str] | None = None,
|
||||
default_message: str | None = None,
|
||||
) -> None:
|
||||
|
||||
self.repo = repo
|
||||
@@ -72,7 +72,7 @@ class HttpRepo(Generic[C, R, U]):
|
||||
|
||||
return item
|
||||
|
||||
def get_one(self, item_id: int | str | UUID4, key: str = None) -> R:
|
||||
def get_one(self, item_id: int | str | UUID4, key: str | None = None) -> R:
|
||||
item = self.repo.get_one(item_id, key)
|
||||
|
||||
if not item:
|
||||
|
||||
@@ -33,7 +33,7 @@ class GroupReportsController(BaseUserController):
|
||||
)
|
||||
|
||||
@router.get("", response_model=list[ReportSummary])
|
||||
def get_all(self, report_type: ReportCategory = None):
|
||||
def get_all(self, report_type: ReportCategory | None = None):
|
||||
return self.repo.multi_query({"group_id": self.group_id, "category": report_type}, limit=9999)
|
||||
|
||||
@router.get("/{item_id}", response_model=ReportOut)
|
||||
|
||||
@@ -22,7 +22,7 @@ class RecipeSharedController(BaseUserController):
|
||||
return HttpRepo[RecipeShareTokenSave, RecipeShareToken, RecipeShareTokenCreate](self.repo, self.logger)
|
||||
|
||||
@router.get("", response_model=list[RecipeShareTokenSummary])
|
||||
def get_all(self, recipe_id: UUID4 = None):
|
||||
def get_all(self, recipe_id: UUID4 | None = None):
|
||||
if recipe_id:
|
||||
return self.repo.multi_query({"recipe_id": recipe_id}, override_schema=RecipeShareTokenSummary)
|
||||
else:
|
||||
@@ -38,5 +38,5 @@ class RecipeSharedController(BaseUserController):
|
||||
return self.mixins.get_one(item_id)
|
||||
|
||||
@router.delete("/{item_id}")
|
||||
def delete_one(self, item_id: UUID4 = None) -> None:
|
||||
def delete_one(self, item_id: UUID4 | None = None) -> None:
|
||||
return self.mixins.delete_one(item_id)
|
||||
|
||||
@@ -37,5 +37,5 @@ class UserImageController(BaseUserController):
|
||||
|
||||
self.repos.users.patch(id, {"cache_key": cache.new_key()})
|
||||
|
||||
if not dest.is_file:
|
||||
if not dest.is_file():
|
||||
raise HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
Reference in New Issue
Block a user