Commit 57d411bd authored by Clément Haëck's avatar Clément Haëck
Browse files

Fix typings

parent d4f2b0f7
import importlib
import logging
from typing import Any, Dict, Callable, List, Set
from typing import Any, Dict, List, Optional
from filefinder import Finder
import xarray as xr
......@@ -14,7 +14,7 @@ logging.basicConfig()
def create_data(module, pregex, get_root, ARGS_DIR,
defaults=None,
open_mf_kw=None):
open_mf_kw: Optional[Dict] = None):
def get_pregex(pregex, args):
if args.get('climato', None) is not None:
......@@ -22,7 +22,7 @@ def create_data(module, pregex, get_root, ARGS_DIR,
return pregex
def get_args_fix(finder):
return set([m.name for m in finder.matchers])
return list(set([m.name for m in finder.matchers]))
def get_finder(args=None, **kwargs):
args = process_args(ARGS_DIR | {'fixes', 'climato'}, args,
......@@ -42,8 +42,8 @@ def create_data(module, pregex, get_root, ARGS_DIR,
return finder.get_filename(args)
if open_mf_kw is None:
open_mf_kw = {}
open_mf_kw_def = dict(
open_mf_kw = dict()
open_mf_kw_def: Dict = dict(
parallel=True
)
open_mf_kw_def.update(open_mf_kw)
......@@ -82,7 +82,8 @@ def get_time_folder(args) -> str:
def process_args(args_names: List[str],
args: Dict = None, replace_defaults: Dict = None,
args: Optional[Dict] = None,
replace_defaults: Optional[Dict] = None,
**kwargs: Any) -> Dict:
"""Process data args.
......@@ -95,7 +96,8 @@ def process_args(args_names: List[str],
return args
def get_data_args(args_names: List[str] = None, args: Dict = None,
def get_data_args(args_names: Optional[List[str]] = None,
args: Optional[Dict] = None,
**kwargs: Any) -> Dict:
"""Put `kwargs` into args.
......@@ -120,7 +122,7 @@ def get_data_args(args_names: List[str] = None, args: Dict = None,
def put_defaults(args_names: List[str],
args: Dict = None, **kwargs: Any) -> Dict:
args: Optional[Dict] = None, **kwargs: Any) -> Dict:
"""Put defaults arguments in args.
Only put those present in `args_names`.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment