mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-30 13:50:42 -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:
@@ -14,7 +14,7 @@ class BackupSchemaMismatch(Exception):
|
||||
|
||||
|
||||
class BackupV2(BaseService):
|
||||
def __init__(self, db_url: str = None) -> None:
|
||||
def __init__(self, db_url: str | None = None) -> None:
|
||||
super().__init__()
|
||||
|
||||
# type - one of these has to be a string
|
||||
|
||||
@@ -28,7 +28,7 @@ class EmailTemplate(BaseModel):
|
||||
|
||||
|
||||
class EmailService(BaseService):
|
||||
def __init__(self, sender: ABCEmailSender = None) -> None:
|
||||
def __init__(self, sender: ABCEmailSender | None = None) -> None:
|
||||
self.templates_dir = CWD / "templates"
|
||||
self.default_template = self.templates_dir / "default.html"
|
||||
self.sender: ABCEmailSender = sender or DefaultEmailSender()
|
||||
|
||||
@@ -79,7 +79,7 @@ class ABCExporter(BaseService):
|
||||
zip (zipfile.ZipFile):
|
||||
"""
|
||||
|
||||
def func(source_dir: Path, dest_dir: str, ignore_ext: set[str] = None) -> None:
|
||||
def func(source_dir: Path, dest_dir: str, ignore_ext: set[str] | None = None) -> None:
|
||||
ignore_ext = ignore_ext or set()
|
||||
|
||||
for source_file in source_dir.iterdir():
|
||||
|
||||
@@ -51,7 +51,7 @@ class InvalidDomainError(Exception):
|
||||
class RecipeDataService(BaseService):
|
||||
minifier: img.ABCMinifier
|
||||
|
||||
def __init__(self, recipe_id: UUID4, group_id: UUID4 = None) -> None:
|
||||
def __init__(self, recipe_id: UUID4, group_id: UUID4 | None = None) -> None:
|
||||
"""
|
||||
RecipeDataService is a service that consolidates the reading/writing actions related
|
||||
to assets, and images for a recipe.
|
||||
|
||||
@@ -84,7 +84,7 @@ class RecipeService(BaseService):
|
||||
self.logger.info(f"Recipe Directory Removed: {recipe.slug}")
|
||||
|
||||
@staticmethod
|
||||
def _recipe_creation_factory(user: PrivateUser, name: str, additional_attrs: dict = None) -> Recipe:
|
||||
def _recipe_creation_factory(user: PrivateUser, name: str, additional_attrs: dict | None = None) -> Recipe:
|
||||
"""
|
||||
The main creation point for recipes. The factor method returns an instance of the
|
||||
Recipe Schema class with the appropriate defaults set. Recipes should not be created
|
||||
|
||||
@@ -96,7 +96,7 @@ class TemplateService(BaseService):
|
||||
|
||||
return save_path
|
||||
|
||||
def _render_jinja2(self, recipe: Recipe, j2_template: str = None) -> Path:
|
||||
def _render_jinja2(self, recipe: Recipe, j2_template: str | None = None) -> Path:
|
||||
"""
|
||||
Renders a Jinja2 Template in a temporary directory and returns
|
||||
the path to the file.
|
||||
|
||||
@@ -229,7 +229,7 @@ def _sanitize_instruction_text(line: str | dict) -> str:
|
||||
return clean_line
|
||||
|
||||
|
||||
def clean_ingredients(ingredients: list | str | None, default: list = None) -> list[str]:
|
||||
def clean_ingredients(ingredients: list | str | None, default: list | None = None) -> list[str]:
|
||||
"""
|
||||
ingredient attempts to parse the ingredients field from a recipe and return a list of
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class RecipeScraper:
|
||||
# List of recipe scrapers. Note that order matters
|
||||
scrapers: list[type[ABCScraperStrategy]]
|
||||
|
||||
def __init__(self, scrapers: list[type[ABCScraperStrategy]] = None) -> None:
|
||||
def __init__(self, scrapers: list[type[ABCScraperStrategy]] | None = None) -> None:
|
||||
if scrapers is None:
|
||||
scrapers = [
|
||||
RecipeScraperPackage,
|
||||
|
||||
@@ -20,9 +20,6 @@ class BackgroundExecutor:
|
||||
self.repos = repos
|
||||
self.background_tasks = bg
|
||||
|
||||
def populate_item(self, _: int) -> ServerTask:
|
||||
pass
|
||||
|
||||
def dispatch(self, task_name: ServerTaskNames, func: Callable, *args: Any, **kwargs: Any) -> ServerTask:
|
||||
"""The dispatch function is a wrapper around the BackgroundTasks class in Starlett. It directly calls
|
||||
the add_task function and your task will be run in the background. This function all passes the id required
|
||||
|
||||
Reference in New Issue
Block a user