Keep option type definitions together...

and update type annotations.
- Since there's no literal for sets, and because functions usually shouldn't be used as parameter defaults, use None as default and then use `set()` as default during init.
This commit is contained in:
awsr
2025-12-18 18:08:54 -08:00
parent 2cd6600a38
commit 05f767cf5f
4 changed files with 13 additions and 14 deletions
+4 -5
View File
@@ -1,13 +1,10 @@
import os
import json
import threading
from typing import TYPE_CHECKING
from modules import cmd_args, errors
from modules.json_helpers import readfile, writefile
from modules.shared_legacy import LegacyOption
from modules.options import OptionInfo, LegacyOption
from installer import log
if TYPE_CHECKING:
from modules.options import OptionInfo
cmd_opts = cmd_args.parse_args()
@@ -21,7 +18,9 @@ class Options():
typemap = {int: float}
debug = os.environ.get('SD_CONFIG_DEBUG', None) is not None
def __init__(self, options_templates:dict={}, restricted_opts:dict={}):
def __init__(self, options_templates: dict[str, OptionInfo | LegacyOption] = {}, restricted_opts: set[str] | None = None):
if restricted_opts is None:
restricted_opts = set()
self.data_labels = options_templates
self.restricted_opts = restricted_opts
self.data = {k: v.default for k, v in self.data_labels.items()}