mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-27 20:55:12 -05:00
chore(deps): update dependency ruff to ^0.9.0 (#4871)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com> Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
@@ -26,8 +26,7 @@ def fix_group_with_no_name(session: Session):
|
||||
return
|
||||
|
||||
logger.info(
|
||||
f'{len(groups)} {"group" if len(groups) == 1 else "groups"} found with a missing name; '
|
||||
f"applying default name"
|
||||
f"{len(groups)} {'group' if len(groups) == 1 else 'groups'} found with a missing name; applying default name"
|
||||
)
|
||||
|
||||
offset = 0
|
||||
|
||||
@@ -51,7 +51,7 @@ def fix_dangling_refs(session: Session):
|
||||
|
||||
if result.rowcount:
|
||||
logger.info(
|
||||
f'Reassigned {result.rowcount} {"row" if result.rowcount == 1 else "rows"} '
|
||||
f"Reassigned {result.rowcount} {'row' if result.rowcount == 1 else 'rows'} "
|
||||
f'in "{table_name}" table to default user ({default_user.id})'
|
||||
)
|
||||
|
||||
@@ -63,7 +63,7 @@ def fix_dangling_refs(session: Session):
|
||||
|
||||
if result.rowcount:
|
||||
logger.info(
|
||||
f'Deleted {result.rowcount} {"row" if result.rowcount == 1 else "rows"} '
|
||||
f"Deleted {result.rowcount} {'row' if result.rowcount == 1 else 'rows'} "
|
||||
f'in "{table_name}" table with invalid user ids'
|
||||
)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class RepositoryCookbooks(HouseholdRepositoryGeneric[ReadCookBook, CookBook]):
|
||||
return super().create(data)
|
||||
except IntegrityError:
|
||||
self.session.rollback()
|
||||
data.slug = slugify(f"{data.name} ({i+1})")
|
||||
data.slug = slugify(f"{data.name} ({i + 1})")
|
||||
|
||||
raise # raise the last IntegrityError
|
||||
|
||||
@@ -45,7 +45,7 @@ class RepositoryCookbooks(HouseholdRepositoryGeneric[ReadCookBook, CookBook]):
|
||||
return super().update(match_value, data)
|
||||
except IntegrityError:
|
||||
self.session.rollback()
|
||||
data.slug = slugify(f"{data.name} ({i+1})")
|
||||
data.slug = slugify(f"{data.name} ({i + 1})")
|
||||
|
||||
raise # raise the last IntegrityError
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class TandoorMigrator(BaseMigrator):
|
||||
recipes_as_dicts: list[dict] = []
|
||||
for i, recipe_zip_file in enumerate(source_dir.glob("*.zip")):
|
||||
try:
|
||||
recipe_dir = str(source_dir.joinpath(f"recipe_{i+1}"))
|
||||
recipe_dir = str(source_dir.joinpath(f"recipe_{i + 1}"))
|
||||
os.makedirs(recipe_dir)
|
||||
|
||||
with zipfile.ZipFile(recipe_zip_file) as recipe_zip:
|
||||
|
||||
@@ -129,10 +129,7 @@ def clean_image(image: str | list | dict | None = None, default: str = "no image
|
||||
case [{"@id": str(_)}, *_]:
|
||||
return [x["@id"] for x in image if "@id" in x]
|
||||
case _:
|
||||
logger.exception(
|
||||
f"Unexpected type for image: {
|
||||
type(image)}, {image}"
|
||||
)
|
||||
logger.exception(f"Unexpected type for image: {type(image)}, {image}")
|
||||
return [default]
|
||||
|
||||
|
||||
@@ -227,10 +224,7 @@ def clean_instructions(steps_object: list | dict | str, default: list | None = N
|
||||
)
|
||||
)
|
||||
case _:
|
||||
raise TypeError(
|
||||
f"Unexpected type for instructions: {
|
||||
type(steps_object)}, {steps_object}"
|
||||
)
|
||||
raise TypeError(f"Unexpected type for instructions: {type(steps_object)}, {steps_object}")
|
||||
|
||||
|
||||
def _sanitize_instruction_text(line: str | dict) -> str:
|
||||
@@ -290,10 +284,7 @@ def clean_ingredients(ingredients: list | str | None, default: list | None = Non
|
||||
case str(ingredients):
|
||||
return [clean_string(ingredient) for ingredient in ingredients.splitlines() if ingredient.strip()]
|
||||
case _:
|
||||
raise TypeError(
|
||||
f"Unexpected type for ingredients: {
|
||||
type(ingredients)}, {ingredients}"
|
||||
)
|
||||
raise TypeError(f"Unexpected type for ingredients: {type(ingredients)}, {ingredients}")
|
||||
|
||||
|
||||
def clean_int(val: str | int | None, min: int | None = None, max: int | None = None):
|
||||
@@ -531,10 +522,7 @@ def clean_categories(category: str | list) -> list[str]:
|
||||
#
|
||||
return [cat["name"] for cat in category if "name" in cat]
|
||||
case _:
|
||||
raise TypeError(
|
||||
f"Unexpected type for category: {
|
||||
type(category)}, {category}"
|
||||
)
|
||||
raise TypeError(f"Unexpected type for category: {type(category)}, {category}")
|
||||
|
||||
|
||||
def clean_tags(data: str | list[str]) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user