mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 05:25:26 +02:00
improve developer tooling (backend) (#1051)
* add basic pre-commit file * add flake8 * add isort * add pep585-upgrade (typing upgrades) * use namespace for import * add mypy * update ci for backend * flake8 scope * fix version format * update makefile * disable strict option (temporary) * fix mypy issues * upgrade type hints (pre-commit) * add vscode typing check * add types to dev deps * remote container draft * update setup script * update compose version * run setup on create * dev containers update * remove unused pages * update setup tips * expose ports * Update pre-commit to include flask8-print (#1053) * Add in flake8-print to pre-commit * pin version of flake8-print * formatting * update getting strated docs * add mypy to pre-commit * purge .mypy_cache on clean * drop mypy Co-authored-by: zackbcom <zackbcom@users.noreply.github.com>
This commit is contained in:
parent
e109391e9a
commit
3c2744a3da
105 changed files with 723 additions and 437 deletions
0
mealie/schema/_mealie/__init__.py
Normal file
0
mealie/schema/_mealie/__init__.py
Normal file
3
mealie/schema/_mealie/types.py
Normal file
3
mealie/schema/_mealie/types.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from typing import Optional
|
||||
|
||||
NoneFloat = Optional[float]
|
|
@ -1,5 +1,5 @@
|
|||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
@ -22,7 +22,7 @@ class ImportJob(BackupOptions):
|
|||
class CreateBackup(BaseModel):
|
||||
tag: Optional[str]
|
||||
options: BackupOptions
|
||||
templates: Optional[List[str]]
|
||||
templates: Optional[list[str]]
|
||||
|
||||
|
||||
class BackupFile(BaseModel):
|
||||
|
@ -32,5 +32,5 @@ class BackupFile(BaseModel):
|
|||
|
||||
|
||||
class AllBackups(BaseModel):
|
||||
imports: List[BackupFile]
|
||||
templates: List[str]
|
||||
imports: list[BackupFile]
|
||||
templates: list[str]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from datetime import datetime
|
||||
from typing import List
|
||||
|
||||
from pydantic.main import BaseModel
|
||||
|
||||
|
@ -17,7 +16,7 @@ class MigrationFile(BaseModel):
|
|||
|
||||
class Migrations(BaseModel):
|
||||
type: str
|
||||
files: List[MigrationFile] = []
|
||||
files: list[MigrationFile] = []
|
||||
|
||||
|
||||
class MigrationImport(RecipeImport):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
from pydantic import UUID4, NoneStr
|
||||
|
||||
# =============================================================================
|
||||
# Group Events Notifier Options
|
||||
|
@ -68,7 +68,7 @@ class GroupEventNotifierSave(GroupEventNotifierCreate):
|
|||
|
||||
class GroupEventNotifierUpdate(GroupEventNotifierSave):
|
||||
id: UUID4
|
||||
apprise_url: str = None
|
||||
apprise_url: NoneStr = None
|
||||
|
||||
|
||||
class GroupEventNotifierOut(CamelModel):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from uuid import UUID
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import NoneStr
|
||||
|
||||
|
||||
class CreateInviteToken(CamelModel):
|
||||
|
@ -29,4 +30,4 @@ class EmailInvitation(CamelModel):
|
|||
|
||||
class EmailInitationResponse(CamelModel):
|
||||
success: bool
|
||||
error: str = None
|
||||
error: NoneStr = None
|
||||
|
|
|
@ -18,7 +18,7 @@ def mapper(source: U, dest: T, **_) -> T:
|
|||
return dest
|
||||
|
||||
|
||||
def cast(source: U, dest: T, **kwargs) -> T:
|
||||
def cast(source: U, dest: type[T], **kwargs) -> T:
|
||||
create_data = {field: getattr(source, field) for field in source.__fields__ if field in dest.__fields__}
|
||||
create_data.update(kwargs or {})
|
||||
return dest(**create_data)
|
||||
|
|
|
@ -3,13 +3,13 @@ from .recipe import *
|
|||
from .recipe_asset import *
|
||||
from .recipe_bulk_actions import *
|
||||
from .recipe_category import *
|
||||
from .recipe_comments import *
|
||||
from .recipe_comments import * # type: ignore
|
||||
from .recipe_image_types import *
|
||||
from .recipe_ingredient import *
|
||||
from .recipe_notes import *
|
||||
from .recipe_nutrition import *
|
||||
from .recipe_settings import *
|
||||
from .recipe_share_token import *
|
||||
from .recipe_share_token import * # type: ignore
|
||||
from .recipe_step import *
|
||||
from .recipe_tool import *
|
||||
from .request_helpers import *
|
||||
|
|
|
@ -7,6 +7,8 @@ from uuid import UUID, uuid4
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4, Field
|
||||
|
||||
from mealie.schema._mealie.types import NoneFloat
|
||||
|
||||
|
||||
class UnitFoodBase(CamelModel):
|
||||
name: str
|
||||
|
@ -23,7 +25,7 @@ class SaveIngredientFood(CreateIngredientFood):
|
|||
|
||||
class IngredientFood(CreateIngredientFood):
|
||||
id: UUID4
|
||||
label: MultiPurposeLabelSummary = None
|
||||
label: Optional[MultiPurposeLabelSummary] = None
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
@ -63,12 +65,12 @@ class RecipeIngredient(CamelModel):
|
|||
|
||||
|
||||
class IngredientConfidence(CamelModel):
|
||||
average: float = None
|
||||
comment: float = None
|
||||
name: float = None
|
||||
unit: float = None
|
||||
quantity: float = None
|
||||
food: float = None
|
||||
average: NoneFloat = None
|
||||
comment: NoneFloat = None
|
||||
name: NoneFloat = None
|
||||
unit: NoneFloat = None
|
||||
quantity: NoneFloat = None
|
||||
food: NoneFloat = None
|
||||
|
||||
|
||||
class ParsedIngredient(CamelModel):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import List
|
||||
import typing
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
@ -22,7 +22,7 @@ class RecipeTool(RecipeToolCreate):
|
|||
|
||||
|
||||
class RecipeToolResponse(RecipeTool):
|
||||
recipes: List["Recipe"] = []
|
||||
recipes: typing.List["Recipe"] = []
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
|
|
@ -11,4 +11,4 @@ class Token(BaseModel):
|
|||
|
||||
class TokenData(BaseModel):
|
||||
user_id: Optional[UUID4]
|
||||
username: Optional[constr(to_lower=True, strip_whitespace=True)] = None
|
||||
username: Optional[constr(to_lower=True, strip_whitespace=True)] = None # type: ignore
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import validator
|
||||
from pydantic.types import constr
|
||||
from pydantic.types import NoneStr, constr
|
||||
|
||||
|
||||
class CreateUserRegistration(CamelModel):
|
||||
group: str = None
|
||||
group_token: str = None
|
||||
email: constr(to_lower=True, strip_whitespace=True)
|
||||
username: constr(to_lower=True, strip_whitespace=True)
|
||||
group: NoneStr = None
|
||||
group_token: NoneStr = None
|
||||
email: constr(to_lower=True, strip_whitespace=True) # type: ignore
|
||||
username: constr(to_lower=True, strip_whitespace=True) # type: ignore
|
||||
password: str
|
||||
password_confirm: str
|
||||
advanced: bool = False
|
||||
|
|
|
@ -53,7 +53,7 @@ class GroupBase(CamelModel):
|
|||
class UserBase(CamelModel):
|
||||
username: Optional[str]
|
||||
full_name: Optional[str] = None
|
||||
email: constr(to_lower=True, strip_whitespace=True)
|
||||
email: constr(to_lower=True, strip_whitespace=True) # type: ignore
|
||||
admin: bool = False
|
||||
group: Optional[str]
|
||||
advanced: bool = False
|
||||
|
@ -107,7 +107,7 @@ class UserOut(UserBase):
|
|||
|
||||
|
||||
class UserFavorites(UserBase):
|
||||
favorite_recipes: list[RecipeSummary] = []
|
||||
favorite_recipes: list[RecipeSummary] = [] # type: ignore
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue