Enable flake8-bugbear linting rules (#267)

See https://docs.astral.sh/ruff/rules/#flake8-bugbear-b.
This commit is contained in:
Marc Wrobel
2023-12-30 10:03:55 +01:00
parent 26f8db809c
commit 0e8fe135e4
13 changed files with 19 additions and 21 deletions

View File

@@ -137,10 +137,10 @@ class Product:
return f"<{self.name}>"
def list_products(method, products_filter=None) -> dict[str, list[dict]]:
def list_products(method, products_filter=None) -> list[str]:
"""Return a list of products that are using the same given update method.
"""
products_with_method = {}
products = []
for product_file in glob(f"{PRODUCTS_PATH}/*.md"):
product_name = os.path.splitext(os.path.basename(product_file))[0]
@@ -150,11 +150,8 @@ def list_products(method, products_filter=None) -> dict[str, list[dict]]:
with open(product_file) as f:
data = frontmatter.load(f)
if "auto" in data:
configs = list(filter(
lambda config: method in config.keys(),
data["auto"]
))
if len(configs) > 0:
products_with_method[product_name] = configs
matching_configs = list(filter(lambda config: method in config.keys(), data["auto"]))
if len(matching_configs) > 0:
products.append(product_name)
return products_with_method
return products

View File

@@ -20,7 +20,7 @@ class Git:
child = run(f"git {cmd}", capture_output=True, timeout=300, check=True, shell=True, cwd=self.repo_dir)
return child.stdout.decode("utf-8").strip().split("\n")
except ChildProcessError as ex:
raise RuntimeError(f"Failed to run '{cmd}': {ex}")
raise RuntimeError(f"Failed to run '{cmd}': {ex}") from ex
def setup(self, bare: bool = False):
"""Creates the repository path and runs: