From 8e244547b84bfd7618f4b4567fcd014655b86a95 Mon Sep 17 00:00:00 2001 From: Sylvain Brunato Date: Mon, 23 Dec 2024 10:29:24 +0100 Subject: [PATCH] refactor: typing fixes following mypy 1.14.0 --- eodag/cli.py | 4 +++- eodag/config.py | 4 +++- eodag/plugins/search/data_request_search.py | 2 +- eodag/plugins/search/qssearch.py | 13 ++++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/eodag/cli.py b/eodag/cli.py index c44121e3c..aab78a10d 100755 --- a/eodag/cli.py +++ b/eodag/cli.py @@ -696,7 +696,9 @@ def serve_rest( try: pid = os.fork() except OSError as e: - raise Exception("%s [%d]" % (e.strerror, e.errno)) + raise Exception( + "%s [%d]" % (e.strerror, e.errno) if e.errno is not None else e.strerror + ) if pid == 0: os.setsid() diff --git a/eodag/config.py b/eodag/config.py index 3ab6c21a3..88b307707 100644 --- a/eodag/config.py +++ b/eodag/config.py @@ -287,8 +287,10 @@ class DiscoverProductTypes(TypedDict, total=False): #: Mapping for product type metadata (e.g. ``abstract``, ``licence``) which can be parsed from the provider #: result generic_product_type_parsable_metadata: Dict[str, str] - #: Mapping for product type properties which can be parsed from the result that are not product type metadata + #: Mapping for product type properties which can be parsed from the result and are not product type metadata generic_product_type_parsable_properties: Dict[str, str] + #: Mapping for product type properties which cannot be parsed from the result and are not product type metadata + generic_product_type_unparsable_properties: Dict[str, str] #: URL to fetch data for a single collection single_collection_fetch_url: str #: Query string to be added to the fetch_url to filter for a collection diff --git a/eodag/plugins/search/data_request_search.py b/eodag/plugins/search/data_request_search.py index ced1eab56..97f97a118 100644 --- a/eodag/plugins/search/data_request_search.py +++ b/eodag/plugins/search/data_request_search.py @@ -116,7 +116,7 @@ class DataRequestSearch(Search): (``Dict[str, str]``): mapping for product type metadata (e.g. ``abstract``, ``licence``) which can be parsed from the provider result * :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.generic_product_type_parsable_properties` - (``Dict[str, str]``): mapping for product type properties which can be parsed from the result that are not + (``Dict[str, str]``): mapping for product type properties which can be parsed from the result and are not product type metadata * :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.single_collection_fetch_url` (``str``): url to fetch data for a single collection; used if product type metadata is not available from the endpoint given in diff --git a/eodag/plugins/search/qssearch.py b/eodag/plugins/search/qssearch.py index 11808fd48..76bd77b09 100644 --- a/eodag/plugins/search/qssearch.py +++ b/eodag/plugins/search/qssearch.py @@ -186,7 +186,10 @@ class QueryStringSearch(Search): (``Dict[str, str]``): mapping for product type metadata (e.g. ``abstract``, ``licence``) which can be parsed from the provider result * :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.generic_product_type_parsable_properties` - (``Dict[str, str]``): mapping for product type properties which can be parsed from the result that are not + (``Dict[str, str]``): mapping for product type properties which can be parsed from the result and are not + product type metadata + * :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.generic_product_type_unparsable_properties` + (``Dict[str, str]``): mapping for product type properties which cannot be parsed from the result and are not product type metadata * :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.single_collection_fetch_url` (``str``): url to fetch data for a single collection; used if product type metadata is not available from the endpoint given in @@ -1038,9 +1041,13 @@ def do_search( logger.debug( "Could not extract total_items_nb from search results" ) - if getattr(self.config, "merge_responses", False): + if ( + getattr(self.config, "merge_responses", False) + and self.config.result_type == "json" + ): + json_result = cast(list[dict[str, Any]], result) results = ( - [dict(r, **result[i]) for i, r in enumerate(results)] + [dict(r, **json_result[i]) for i, r in enumerate(results)] if results else result )