From 8fdee29205deb85485fafe742b6e4ddade191eb8 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Thu, 14 Nov 2024 16:34:13 +0100 Subject: backend/lint: Stop using mutable objects as function argument defaults See https://docs.astral.sh/ruff/rules/mutable-argument-default/ --- src/hircine/db/ops.py | 10 ++++++++-- src/hircine/scraper/__init__.py | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/hircine/db/ops.py b/src/hircine/db/ops.py index c164cd2..e61c5ad 100644 --- a/src/hircine/db/ops.py +++ b/src/hircine/db/ops.py @@ -124,7 +124,10 @@ def lookup_identity(session, model, ids): return objects, satisfied -async def get_all(session, model, ids, options=[], use_identity_map=False): +async def get_all(session, model, ids, options=None, use_identity_map=False): + if not options: + options = [] + objects = [] ids = set(ids) @@ -146,7 +149,10 @@ async def get_all(session, model, ids, options=[], use_identity_map=False): return objects, missing -async def get_all_names(session, model, names, options=[]): +async def get_all_names(session, model, names, options=None): + if not options: + options = [] + names = set(names) sql = select(model).where(model.name.in_(names)).options(*options) diff --git a/src/hircine/scraper/__init__.py b/src/hircine/scraper/__init__.py index c04265a..bc83436 100644 --- a/src/hircine/scraper/__init__.py +++ b/src/hircine/scraper/__init__.py @@ -81,7 +81,10 @@ class Scraper(ABC): """ pass - def collect(self, transformers=[]): + def collect(self, transformers=None): + if transformers is None: + transformers = [] + def generator(): for result in self.scrape(): if callable(result): -- cgit v1.2.3-2-gb3c3