From c46eb68305bc43b5ca7c9dc0212a11fa060f5b14 Mon Sep 17 00:00:00 2001 From: Justus Kuhlmann Date: Tue, 2 Dec 2025 12:35:41 +0100 Subject: [PATCH] correct mypy issues II --- corrlib/input/openQCD.py | 8 ++++---- corrlib/input/sfcf.py | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/corrlib/input/openQCD.py b/corrlib/input/openQCD.py index 0342a00..e0caba6 100644 --- a/corrlib/input/openQCD.py +++ b/corrlib/input/openQCD.py @@ -2,7 +2,7 @@ import pyerrors.input.openQCD as input import datalad.api as dl import os import fnmatch -from typing import Any +from typing import Any, Optional def read_ms1_param(path: str, project: str, file_in_project: str) -> dict[str, Any]: @@ -67,7 +67,7 @@ def read_ms3_param(path: str, project: str, file_in_project: str) -> dict[str, A return param -def read_rwms(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, postfix: str="ms1", version: str='2.0', names: list[str]=None, files: list[str]=None) -> dict[str, Any]: +def read_rwms(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, postfix: str="ms1", version: str='2.0', names: Optional[list[str]]=None, files: Optional[list[str]]=None) -> dict[str, Any]: dataset = os.path.join(path, "projects", project) directory = os.path.join(dataset, dir_in_project) if files is None: @@ -94,7 +94,7 @@ def read_rwms(path: str, project: str, dir_in_project: str, param: dict[str, Any return rw_dict -def extract_t0(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, dtr_read: int, xmin: int, spatial_extent: int, fit_range: int = 5, postfix: str=None, names: list[str]=None, files: list[str]=None) -> dict[str, Any]: +def extract_t0(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, dtr_read: int, xmin: int, spatial_extent: int, fit_range: int = 5, postfix: str="", names: Optional[list[str]]=None, files: Optional[list[str]]=None) -> dict[str, Any]: dataset = os.path.join(path, "projects", project) directory = os.path.join(dataset, dir_in_project) if files is None: @@ -132,7 +132,7 @@ def extract_t0(path: str, project: str, dir_in_project: str, param: dict[str, An return t0_dict -def extract_t1(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, dtr_read: int, xmin: int, spatial_extent: int, fit_range: int = 5, postfix: str = None, names: list[str]=None, files: list[str]=None) -> dict[str, Any]: +def extract_t1(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, dtr_read: int, xmin: int, spatial_extent: int, fit_range: int = 5, postfix: str = "", names: Optional[list[str]]=None, files: Optional[list[str]]=None) -> dict[str, Any]: directory = os.path.join(path, "projects", project, dir_in_project) if files is None: files = [] diff --git a/corrlib/input/sfcf.py b/corrlib/input/sfcf.py index c8a5d46..ed5a45a 100644 --- a/corrlib/input/sfcf.py +++ b/corrlib/input/sfcf.py @@ -5,7 +5,7 @@ import os from typing import Any -bi_corrs: list = ["f_P", "fP", "f_p", +bi_corrs: list[str] = ["f_P", "fP", "f_p", "g_P", "gP", "g_p", "fA0", "f_A", "f_a", "gA0", "g_A", "g_a", @@ -43,7 +43,7 @@ bi_corrs: list = ["f_P", "fP", "f_p", "l3A2", "l3_A2", "g_av23", ] -bb_corrs: list = [ +bb_corrs: list[str] = [ 'F1', 'F_1', 'f_1', @@ -64,7 +64,7 @@ bb_corrs: list = [ 'F_sPdP_d', ] -bib_corrs: list = [ +bib_corrs: list[str] = [ 'F_V0', 'K_V0', ] @@ -184,7 +184,7 @@ def read_param(path: str, project: str, file_in_project: str) -> dict[str, Any]: return params -def _map_params(params: dict, spec_list: list) -> dict[str, Any]: +def _map_params(params: dict[str, Any], spec_list: list[str]) -> dict[str, Any]: """ Map the extracted parameters to the extracted data. @@ -194,7 +194,7 @@ def _map_params(params: dict, spec_list: list) -> dict[str, Any]: The parameters extracted from the parameter (input) file. in the dict form given by read_param. spec_list: list The list of specifications that belongs to the dorrelator in question. - + Return ------ new_specs: dict @@ -228,7 +228,7 @@ def _map_params(params: dict, spec_list: list) -> dict[str, Any]: return new_specs -def get_specs(key, parameters, sep='/') -> str: +def get_specs(key: str, parameters: dict[str, Any], sep: str = '/') -> str: key_parts = key.split(sep) if corr_types[key_parts[0]] == 'bi': param = _map_params(parameters, key_parts[1:-1]) @@ -238,7 +238,7 @@ def get_specs(key, parameters, sep='/') -> str: return s -def read_data(path, project, dir_in_project, prefix, param, version='1.0c', cfg_seperator='n', sep='/', **kwargs) -> dict: +def read_data(path: str, project: str, dir_in_project: str, prefix: str, param: dict[str, Any], version: str = '1.0c', cfg_seperator: str = 'n', sep: str = '/', **kwargs: Any) -> dict[str, Any]: """ Extract the data from the sfcf file.