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:
Hayden
2023-01-01 14:47:27 -08:00
committed by GitHub
parent e329e1cd15
commit 4d5550ad85
27 changed files with 173 additions and 135 deletions

View File

@@ -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

View File

@@ -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()

View File

@@ -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():

View File

@@ -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.

View File

@@ -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

View File

@@ -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.

View 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

View File

@@ -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,

View File

@@ -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