diff --git a/disdrodb/configs.py b/disdrodb/configs.py index 9c416d89..cae6df14 100644 --- a/disdrodb/configs.py +++ b/disdrodb/configs.py @@ -5,7 +5,6 @@ @author: ghiggi """ import os -from typing import Dict from disdrodb.utils.yaml import read_yaml, write_yaml @@ -66,7 +65,7 @@ def define_disdrodb_configs(base_dir: str = None, zenodo_token: str = None, zeno return -def read_disdrodb_configs() -> Dict[str, str]: +def read_disdrodb_configs() -> dict[str, str]: """ Reads the DISDRODB configuration file and returns a dictionary with the configuration settings. diff --git a/disdrodb/data_transfer/download_data.py b/disdrodb/data_transfer/download_data.py index 5fb5e566..431ecc85 100644 --- a/disdrodb/data_transfer/download_data.py +++ b/disdrodb/data_transfer/download_data.py @@ -20,7 +20,7 @@ import os import shutil -from typing import List, Optional, Union +from typing import Optional, Union import click import pooch @@ -97,9 +97,9 @@ def click_download_options(function: object): def download_archive( - data_sources: Optional[Union[str, List[str]]] = None, - campaign_names: Optional[Union[str, List[str]]] = None, - station_names: Optional[Union[str, List[str]]] = None, + data_sources: Optional[Union[str, list[str]]] = None, + campaign_names: Optional[Union[str, list[str]]] = None, + station_names: Optional[Union[str, list[str]]] = None, force: bool = False, base_dir: Optional[str] = None, ): @@ -222,7 +222,7 @@ def _has_disdrodb_data_url(metadata_filepath): return _is_valid_disdrodb_data_url(disdrodb_data_url) -def _select_metadata_with_remote_data_url(metadata_filepaths: List[str]) -> List[str]: +def _select_metadata_with_remote_data_url(metadata_filepaths: list[str]) -> list[str]: """Select metadata files that have a remote data url specified.""" return [fpath for fpath in metadata_filepaths if _has_disdrodb_data_url(fpath)] diff --git a/disdrodb/data_transfer/upload_data.py b/disdrodb/data_transfer/upload_data.py index a91368fc..b26a175d 100644 --- a/disdrodb/data_transfer/upload_data.py +++ b/disdrodb/data_transfer/upload_data.py @@ -18,7 +18,7 @@ # -----------------------------------------------------------------------------. """Routines to upload data to the DISDRODB Decentralized Data Archive.""" -from typing import List, Optional +from typing import Optional import click @@ -95,7 +95,7 @@ def _check_if_upload(metadata_filepath: str, force: bool): raise ValueError(f"'force' is False and {metadata_filepath} has already a 'disdrodb_data_url' specified.") -def _filter_already_uploaded(metadata_filepaths: List[str], force: bool) -> List[str]: +def _filter_already_uploaded(metadata_filepaths: list[str], force: bool) -> list[str]: """Filter metadata files that already have a remote url specified.""" filtered = [] for metadata_filepath in metadata_filepaths: diff --git a/disdrodb/data_transfer/zenodo.py b/disdrodb/data_transfer/zenodo.py index ad5ca5f5..859dd0d9 100644 --- a/disdrodb/data_transfer/zenodo.py +++ b/disdrodb/data_transfer/zenodo.py @@ -20,7 +20,6 @@ import json import os -from typing import Tuple import requests @@ -52,7 +51,7 @@ def _check_http_response( raise ValueError(error_message) -def _create_zenodo_deposition(sandbox) -> Tuple[int, str]: +def _create_zenodo_deposition(sandbox) -> tuple[int, str]: """Create a new Zenodo deposition and get the deposit information. At every function call, the deposit_id and bucket url will change ! diff --git a/disdrodb/l0/check_configs.py b/disdrodb/l0/check_configs.py index 18d5e265..446de15c 100644 --- a/disdrodb/l0/check_configs.py +++ b/disdrodb/l0/check_configs.py @@ -19,7 +19,7 @@ """Check configuration files.""" import os -from typing import List, Optional, Union +from typing import Optional, Union import numpy as np from pydantic import BaseModel, ValidationError, field_validator, model_validator @@ -134,7 +134,7 @@ class L0BEncodingSchema(BaseModel): shuffle: bool fletcher32: bool _FillValue: Optional[Union[int, float]] - chunksizes: Optional[Union[int, List[int]]] + chunksizes: Optional[Union[int, list[int]]] # if contiguous=False, chunksizes specified, otherwise should be not ! @model_validator(mode="before") @@ -212,10 +212,10 @@ class RawDataFormatSchema(BaseModel): n_characters: Optional[int] n_decimals: Optional[int] n_naturals: Optional[int] - data_range: Optional[List[float]] + data_range: Optional[list[float]] nan_flags: Optional[Union[int, str]] = None - valid_values: Optional[List[float]] = None - dimension_order: Optional[List[str]] = None + valid_values: Optional[list[float]] = None + dimension_order: Optional[list[str]] = None n_values: Optional[int] = None field_number: Optional[str] = None diff --git a/disdrodb/tests/test_l0/test_config_files.py b/disdrodb/tests/test_l0/test_config_files.py index f6581856..c0a9be30 100644 --- a/disdrodb/tests/test_l0/test_config_files.py +++ b/disdrodb/tests/test_l0/test_config_files.py @@ -18,7 +18,7 @@ # -----------------------------------------------------------------------------. """Check DISDRODB L0 configuration files.""" import os -from typing import Dict, Union +from typing import Union import pytest import yaml @@ -30,7 +30,7 @@ CONFIG_FOLDER = os.path.join(__root_path__, "disdrodb", "l0", "configs") -def read_yaml_file(filepath: str) -> Dict: +def read_yaml_file(filepath: str) -> dict: """Read a YAML file and return a dictionary. Parameters diff --git a/disdrodb/utils/netcdf.py b/disdrodb/utils/netcdf.py index e09f7125..603ac83f 100644 --- a/disdrodb/utils/netcdf.py +++ b/disdrodb/utils/netcdf.py @@ -19,7 +19,6 @@ """DISDRODB netCDF utility.""" import logging -from typing import Tuple import numpy as np import pandas as pd @@ -31,7 +30,7 @@ ####---------------------------------------------------------------------------. -def _sort_datasets_by_dim(list_ds: list, filepaths: str, dim: str = "time") -> Tuple[list, list]: +def _sort_datasets_by_dim(list_ds: list, filepaths: str, dim: str = "time") -> tuple[list, list]: """Sort a list of xarray.Dataset and corresponding file paths by the starting value of a specified dimension. Parameters @@ -55,7 +54,7 @@ def _sort_datasets_by_dim(list_ds: list, filepaths: str, dim: str = "time") -> T return sorted_list_ds, sorted_filepaths -def _get_dim_values_index(list_ds: list, dim: str) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: +def _get_dim_values_index(list_ds: list, dim: str) -> tuple[np.ndarray, np.ndarray, np.ndarray]: """Get list and dataset indices associated to the dimension values.""" dim_values = np.concatenate([ds[dim].values for ds in list_ds]) list_index = np.concatenate([np.ones(len(ds[dim])) * i for i, ds in enumerate(list_ds)]) @@ -129,7 +128,7 @@ def _get_bad_info_dict( list_index: np.ndarray, dim_values: np.ndarray, ds_index: np.ndarray, -) -> Tuple[dict, dict]: +) -> tuple[dict, dict]: """Return two dictionaries mapping, for each dataset, the bad values and indices to remove. Parameters