fix(typing): resolve mypy errors in config

This commit is contained in:
Mark Paronyan 2026-09-28 04:42:58 +00:00
parent 8df25dec32
commit 2512556770
No known key found for this signature in database
2 changed files with 6 additions and 3 deletions

View File

@ -48,6 +48,10 @@ class ConfigConflictError(Exception):
LIST_OPTION_SEPARATORS = {"additional_images_paths": ";"}
def parser_sections(parser: configparser.ConfigParser) -> dict[str, dict[str, str]]:
return {section: dict(parser[section]) for section in parser.sections()}
class Config:
"""
Configuration file management using configparser.
@ -328,7 +332,7 @@ class Config:
changed.append(f"{section}.{option}")
# validate the merged settings before touching the file on disk
ServerConfig(**merged_parser._sections)
ServerConfig(**parser_sections(merged_parser))
directory_name = os.path.dirname(main_config_file)
if directory_name:
@ -414,7 +418,7 @@ class Config:
self._watched_files[file] = os.stat(file).st_mtime
try:
self._settings = ServerConfig(**config._sections)
self._settings = ServerConfig(**parser_sections(config))
except ValidationError as e:
log.critical(f"Could not validate configuration file settings: {e}")
raise

View File

@ -372,7 +372,6 @@ module = [
"gns3server.compute.virtualbox.virtualbox_vm", # 1
"gns3server.compute.vmware.vmware_vm", # 1
"gns3server.compute.vpcs.vpcs_vm", # 2
"gns3server.config", # 1
"gns3server.controller.appliance", # 2
"gns3server.controller.appliance_manager", # 5
"gns3server.controller.compute", # 2