Merge pull request #2884 from markparonyan/mypy-config

fix(typing): resolve mypy errors in config
This commit is contained in:
Jeremy Grossmann 2026-09-28 10:54:17 +02:00 committed by GitHub
commit 0bd1204d15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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

@ -371,7 +371,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