diff options
author | Wolfgang Müller | 2024-11-14 16:34:13 +0100 |
---|---|---|
committer | Wolfgang Müller | 2024-11-14 16:51:56 +0100 |
commit | 8fdee29205deb85485fafe742b6e4ddade191eb8 (patch) | |
tree | 53503e9a3a52d938f88abf2e487447e53e2beb14 | |
parent | 15ac18049f56e4a8dd4f4ae81c066901573b62a9 (diff) | |
download | hircine-8fdee29205deb85485fafe742b6e4ddade191eb8.tar.gz |
backend/lint: Stop using mutable objects as function argument defaults
See https://docs.astral.sh/ruff/rules/mutable-argument-default/
-rw-r--r-- | src/hircine/db/ops.py | 10 | ||||
-rw-r--r-- | src/hircine/scraper/__init__.py | 5 |
2 files changed, 12 insertions, 3 deletions
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): |