Skip to content

Commit a6b2171

Browse files
committed
refactor: AssetsDict.update
1 parent 6003491 commit a6b2171

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

eodag/api/product/_assets.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import logging
2121
import re
2222
from collections import UserDict
23-
from typing import TYPE_CHECKING, Any, Optional, Union
23+
from typing import TYPE_CHECKING, Any, Optional
2424

2525
from typing_extensions import override
2626

@@ -78,13 +78,14 @@ def __setitem__(self, key: str, value: dict[str, Any]) -> None:
7878
self._update_product_location()
7979

8080
@override
81-
def update(self, value: Union[dict[str, Any], AssetsDict]) -> None: # type: ignore
82-
"""Used to self update with exernal value"""
83-
buffer: dict = {}
84-
for key in value:
85-
if self._check(key, value[key]):
86-
buffer[key] = value[key]
87-
super().update(buffer)
81+
def update(self, *args: Any, **kwargs: Any) -> None:
82+
"""Used to self update with external value"""
83+
incoming = {k: v for k, v in dict(*args, **kwargs).items() if self._check(k, v)}
84+
85+
if not incoming:
86+
return
87+
88+
super().update(incoming)
8889
self.sort()
8990
self._update_product_location()
9091

0 commit comments

Comments
 (0)