2525import logging
2626import os
2727from dataclasses import dataclass
28- from typing import Any , Dict , Optional , Set
28+ from typing import Any
2929
3030import yaml
3131
@@ -48,11 +48,11 @@ class ArgSpec:
4848 help : str
4949 default : Any = None
5050 type : Any = None
51- action : Optional [ str ] = None
52- nargs : Optional [ str ] = None
51+ action : str | None = None
52+ nargs : str | None = None
5353
5454
55- ARG_SPECS : Dict [str , ArgSpec ] = {
55+ ARG_SPECS : dict [str , ArgSpec ] = {
5656 "top_traj_file" : ArgSpec (
5757 type = str ,
5858 nargs = "+" ,
@@ -145,6 +145,12 @@ class ArgSpec:
145145 default = True ,
146146 help = "Use bonded axes to rotate forces for UA level vibrational entropies" ,
147147 ),
148+ "search_type" : ArgSpec (
149+ type = str ,
150+ default = "RAD" ,
151+ help = "Type of neighbor search to use."
152+ "Default RAD; grid search is also available" ,
153+ ),
148154}
149155
150156
@@ -159,7 +165,7 @@ class ConfigResolver:
159165 - validating trajectory-related numeric parameters
160166 """
161167
162- def __init__ (self , arg_specs : Optional [ Dict [ str , ArgSpec ]] = None ) -> None :
168+ def __init__ (self , arg_specs : dict [ str , ArgSpec ] | None = None ) -> None :
163169 """Initialize the manager.
164170
165171 Args:
@@ -168,7 +174,7 @@ def __init__(self, arg_specs: Optional[Dict[str, ArgSpec]] = None) -> None:
168174 """
169175 self ._arg_specs = dict (arg_specs or ARG_SPECS )
170176
171- def load_config (self , directory_path : str ) -> Dict [str , Any ]:
177+ def load_config (self , directory_path : str ) -> dict [str , Any ]:
172178 """Load the first YAML config file found in a directory.
173179
174180 The current behavior matches your existing workflow:
@@ -188,7 +194,7 @@ def load_config(self, directory_path: str) -> Dict[str, Any]:
188194
189195 config_path = yaml_files [0 ]
190196 try :
191- with open (config_path , "r" , encoding = "utf-8" ) as file :
197+ with open (config_path , encoding = "utf-8" ) as file :
192198 config = yaml .safe_load (file ) or {"run1" : {}}
193199 logger .info ("Loaded configuration from: %s" , config_path )
194200 return config
@@ -253,7 +259,7 @@ def build_parser(self) -> argparse.ArgumentParser:
253259 )
254260 continue
255261
256- kwargs : Dict [str , Any ] = {}
262+ kwargs : dict [str , Any ] = {}
257263 if spec .type is not None :
258264 kwargs ["type" ] = spec .type
259265 if spec .default is not None :
@@ -266,7 +272,7 @@ def build_parser(self) -> argparse.ArgumentParser:
266272 return parser
267273
268274 def resolve (
269- self , args : argparse .Namespace , run_config : Optional [ Dict [ str , Any ]]
275+ self , args : argparse .Namespace , run_config : dict [ str , Any ] | None
270276 ) -> argparse .Namespace :
271277 """Merge CLI arguments with YAML configuration and adjust logging level.
272278
@@ -306,8 +312,8 @@ def resolve(
306312
307313 @staticmethod
308314 def _detect_cli_overrides (
309- args_dict : Dict [str , Any ], default_dict : Dict [str , Any ]
310- ) -> Set [str ]:
315+ args_dict : dict [str , Any ], default_dict : dict [str , Any ]
316+ ) -> set [str ]:
311317 """Detect which args were explicitly overridden in the CLI.
312318
313319 Args:
@@ -322,8 +328,8 @@ def _detect_cli_overrides(
322328 def _apply_yaml_defaults (
323329 self ,
324330 args : argparse .Namespace ,
325- run_config : Dict [str , Any ],
326- cli_provided : Set [str ],
331+ run_config : dict [str , Any ],
332+ cli_provided : set [str ],
327333 ) -> None :
328334 """Apply YAML values onto args for keys not provided by CLI.
329335
@@ -336,7 +342,7 @@ def _apply_yaml_defaults(
336342 if yaml_value is None or key in cli_provided :
337343 continue
338344 if key in self ._arg_specs :
339- logger .debug ("Using YAML value for %s: %s" , key , yaml_value )
345+ logger .debug (f "Using YAML value for { key } : { yaml_value } " )
340346 setattr (args , key , yaml_value )
341347
342348 def _ensure_defaults (self , args : argparse .Namespace ) -> None :
0 commit comments