chore: upgrade pre-commit hooks (#1735)

* change pep585 hook to pyupgrade

* run pyupgrade + cleanup lint errors
This commit is contained in:
Hayden
2022-10-17 14:37:06 -08:00
committed by GitHub
parent e516a2e801
commit a8f0fb14a7
13 changed files with 79 additions and 83 deletions

View File

@@ -36,7 +36,7 @@ class BackupContents:
def read_tables(self) -> dict:
if self._tables is None:
with open(self.tables, "r") as f:
with open(self.tables) as f:
self._tables = json.load(f)
return self._tables

View File

@@ -10,7 +10,7 @@ from mealie.services.recipe.recipe_data_service import RecipeDataService
class MigrationReaders:
@staticmethod
def json(json_file: Path) -> dict:
with open(json_file, "r") as f:
with open(json_file) as f:
return json.loads(f.read())
@staticmethod
@@ -24,7 +24,7 @@ class MigrationReaders:
Returns:
dict: representing the yaml file as a dictionary
"""
with open(yaml_file, "r") as f:
with open(yaml_file) as f:
contents = f.read().split("---")
recipe_data = {}
for document in contents:

View File

@@ -95,7 +95,7 @@ def insideParenthesis(token, tokens):
else:
line = " ".join(tokens)
return (
re.match(r".*\(.*" + re.escape(token) + ".*\).*", line) is not None # noqa: W605 - invalid dscape sequence
re.match(r".*\(.*" + re.escape(token) + r".*\).*", line) is not None # noqa: W605 - invalid dscape sequence
)
@@ -107,7 +107,7 @@ def displayIngredient(ingredient):
# => <span class='qty'>1</span> <span class='name'>cat pie</span>
"""
return "".join(["<span class='%s'>%s</span>" % (tag, " ".join(tokens)) for tag, tokens in ingredient])
return "".join(["<span class='{}'>{}</span>".format(tag, " ".join(tokens)) for tag, tokens in ingredient])
# HACK: fix this
@@ -189,7 +189,7 @@ def import_data(lines):
# turn B-NAME/123 back into "name"
tag, confidence = re.split(r"/", columns[-1], 1)
tag = re.sub("^[BI]\-", "", tag).lower() # noqa: W605 - invalid dscape sequence
tag = re.sub(r"^[BI]\-", "", tag).lower() # noqa: W605 - invalid dscape sequence
# ====================
# Confidence Getter
@@ -231,9 +231,7 @@ def import_data(lines):
data[-1][tag].append(token)
# reassemble the output into a list of dicts.
output = [
dict([(k, smartJoin(tokens)) for k, tokens in ingredient.items()]) for ingredient in data if len(ingredient)
]
output = [{k: smartJoin(tokens) for k, tokens in ingredient.items()} for ingredient in data if len(ingredient)]
# Preclean Confidence
for i, c in enumerate(confidence_all):

View File

@@ -105,7 +105,7 @@ class TemplateService(BaseService):
if not j2_path.is_file():
raise FileNotFoundError(f"Template '{j2_path}' not found.")
with open(j2_path, "r") as f:
with open(j2_path) as f:
template_text = f.read()
template = Template(template_text)