Skip to content

Commit

Permalink
mypy fixes for ci/cd pipeline #45
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoHuebner committed Aug 26, 2022
1 parent 07ff06f commit 8994f1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/pygenesis/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ def clean_cache(file: Optional[str]) -> None:
)

# remove specified file (directory) from the data cache or clear complete cache
file_path = (
cache_dir / cache_dir.glob(file) if file is not None else cache_dir
)
# TODO: Find corresponding directories with cache_dir.glob(file)
file_path = cache_dir / file if file is not None else cache_dir

try:
if file_path.is_file() or file_path.is_symlink():
Expand Down
16 changes: 9 additions & 7 deletions src/pygenesis/destatis.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Module provides functions to work with the GENESIS REST-API."""
from typing import Any

from pygenesis.config import load_config
from pygenesis.http_helper import get_response_from_endpoint

config = load_config()


def get_metadata(endpoint: str, name: str) -> str:
def get_metadata(endpoint: str, name: str) -> Any:
"""Method for downloading metadata from www-genesis.destatis.de.
Method supports the following endpoints:
Expand All @@ -21,37 +23,37 @@ def get_metadata(endpoint: str, name: str) -> str:
name (str): Unique name of the object.
Returns:
str: Content of "Object" response.
Any: JSON formatted content of "Object" response.
"""
params = {
"name": name,
}

return get_response_from_endpoint("metadata", endpoint, params).text
return get_response_from_endpoint("metadata", endpoint, params).json()


def get_catalogue(endpoint: str, params: dict) -> dict:
def get_catalogue(endpoint: str, params: dict) -> Any:
"""Method for downloading catalogue data from www-genesis.destatis.de.
Args:
endpoint (str): One of the supported endpoints, e.g. cubes.
params (dict): The query parameter as defined by the API.
Returns:
dict: JSON formated response for the given query parameters.
Any: JSON formated response for the given query parameters.
"""

return get_response_from_endpoint("catalogue", endpoint, params).json()


def get_cubefile(params: dict) -> str:
def get_cubefile(params: dict) -> Any:
"""Method for downloading cube files from www-genesis.destatis.de.
Args:
params (dict): The query parameter as defined by the API.
Returns:
str: The content of the cubefile.
Any: The content of the cubefile.
"""

return get_response_from_endpoint("data", "cubefile", params).text
6 changes: 3 additions & 3 deletions src/pygenesis/http_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def _check_destatis_status(destatis_status: dict) -> None:
ValueError: If the status code or type displays an error (caused by the user inputs)
"""
# -1 status code for unexpected errors and if no status code is given (faulty response)
destatis_status_code = destatis_status.get("Code", -1)
destatis_status_type = destatis_status.get("Type")
destatis_status_content = destatis_status.get("Content")
destatis_status_code = int(destatis_status.get("Code", -1))
destatis_status_type = str(destatis_status.get("Type", "Information"))
destatis_status_content = str(destatis_status.get("Content"))

# define status types
error_en_de = ["Error", "Fehler"]
Expand Down

0 comments on commit 8994f1b

Please sign in to comment.