From cb92fe89d5e94de1b5a841cdb16447a0c1a4e5a8 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Fri, 8 Dec 2023 22:53:24 +0100 Subject: [PATCH] fix: fix type issues --- sw360/components.py | 7 +++++-- sw360/releases.py | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sw360/components.py b/sw360/components.py index debb676..d2f48d4 100644 --- a/sw360/components.py +++ b/sw360/components.py @@ -9,7 +9,8 @@ # SPDX-License-Identifier: MIT # ------------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional +import sys +from typing import Any, Dict, List, Optional, Union import requests @@ -18,9 +19,11 @@ class ComponentsMixin(BaseMixin): + # return type List[Dict[str, Any]] | Optional[Dict[str, Any]] for Python 3.11 is good, + # Union[List[Dict[str, Any]], Optional[Dict[str, Any]]] for lower Python versions is not good def get_all_components(self, fields=None, page=-1, page_size=-1, all_details: bool = False, - sort: str = "") -> List[Dict[str, Any]] | Optional[Dict[str, Any]]: + sort: str = "") -> Any: """Get information of about all components API endpoint: GET /components diff --git a/sw360/releases.py b/sw360/releases.py index db7c83a..044d507 100644 --- a/sw360/releases.py +++ b/sw360/releases.py @@ -64,8 +64,10 @@ def get_releases_by_name(self, name: str) -> List[Any]: return [] + # return type List[Dict[str, Any]] | Optional[Dict[str, Any]] for Python 3.11 is good, + # Union[List[Dict[str, Any]], Optional[Dict[str, Any]]] for lower Python versions is not good def get_all_releases(self, fields: str = "", all_details: bool = False, page: int = -1, - page_size: int = -1, sort: str = "") -> List[Dict[str, Any]] | Optional[Dict[str, Any]]: + page_size: int = -1, sort: str = "") -> Any: """Get information of about all releases API endpoint: GET /releases