|
4 | 4 |
|
5 | 5 | import functools |
6 | 6 | import warnings |
7 | | -from typing import Any, Dict, Tuple, Optional |
| 7 | +from typing import Any, Callable, cast, Dict, Iterable, List, Tuple, Optional, Union |
8 | 8 | from time import time, perf_counter, get_clock_info |
9 | 9 | import json |
10 | 10 | import os |
@@ -156,16 +156,19 @@ def load_config( |
156 | 156 | config = {} |
157 | 157 |
|
158 | 158 | # use the given dict for default values |
159 | | - config_sources = [ |
160 | | - given_config, |
161 | | - can.rc, |
162 | | - lambda _context: load_environment_config( # pylint: disable=unnecessary-lambda |
163 | | - _context |
164 | | - ), |
165 | | - lambda _context: load_environment_config(), |
166 | | - lambda _context: load_file_config(path, _context), |
167 | | - lambda _context: load_file_config(path), |
168 | | - ] |
| 159 | + config_sources = cast( |
| 160 | + Iterable[Union[Dict[str, Any], Callable[[Any], Dict[str, Any]]]], |
| 161 | + [ |
| 162 | + given_config, |
| 163 | + can.rc, |
| 164 | + lambda _context: load_environment_config( # pylint: disable=unnecessary-lambda |
| 165 | + _context |
| 166 | + ), |
| 167 | + lambda _context: load_environment_config(), |
| 168 | + lambda _context: load_file_config(path, _context), |
| 169 | + lambda _context: load_file_config(path), |
| 170 | + ], |
| 171 | + ) |
169 | 172 |
|
170 | 173 | # Slightly complex here to only search for the file config if required |
171 | 174 | for cfg in config_sources: |
@@ -216,7 +219,8 @@ def load_config( |
216 | 219 | config["timing"] = can.BitTiming(**timing_conf) |
217 | 220 |
|
218 | 221 | can.log.debug("can config: %s", config) |
219 | | - return config |
| 222 | + |
| 223 | + return cast(typechecking.BusConfig, config) |
220 | 224 |
|
221 | 225 |
|
222 | 226 | def set_logging_level(level_name: str) -> None: |
|
0 commit comments