Skip to content

Commit 9fd6932

Browse files
Merge pull request #15211 from light-and-ray/type_hintinh_in_shared.py
type hinting in shared.py
2 parents f7bad19 + 2d57a2d commit 9fd6932

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

modules/shared.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from modules import shared_cmd_options, shared_gradio_themes, options, shared_items, sd_models_types
77
from modules.paths_internal import models_path, script_path, data_path, sd_configs_path, sd_default_config, sd_model_file, default_sd_model_file, extensions_dir, extensions_builtin_dir # noqa: F401
88
from modules import util
9+
from typing import TYPE_CHECKING
10+
11+
if TYPE_CHECKING:
12+
from modules import shared_state, styles, interrogate, shared_total_tqdm, memmon
913

1014
cmd_opts = shared_cmd_options.cmd_opts
1115
parser = shared_cmd_options.parser
@@ -16,33 +20,33 @@
1620
config_filename = cmd_opts.ui_settings_file
1721
hide_dirs = {"visible": not cmd_opts.hide_ui_dir_config}
1822

19-
demo = None
23+
demo: gr.Blocks = None
2024

21-
device = None
25+
device: str = None
2226

23-
weight_load_location = None
27+
weight_load_location: str = None
2428

2529
xformers_available = False
2630

2731
hypernetworks = {}
2832

2933
loaded_hypernetworks = []
3034

31-
state = None
35+
state: 'shared_state.State' = None
3236

33-
prompt_styles = None
37+
prompt_styles: 'styles.StyleDatabase' = None
3438

35-
interrogator = None
39+
interrogator: 'interrogate.InterrogateModels' = None
3640

3741
face_restorers = []
3842

39-
options_templates = None
40-
opts = None
41-
restricted_opts = None
43+
options_templates: dict = None
44+
opts: options.Options = None
45+
restricted_opts: set[str] = None
4246

4347
sd_model: sd_models_types.WebuiSdModel = None
4448

45-
settings_components = None
49+
settings_components: dict = None
4650
"""assigned from ui.py, a mapping on setting names to gradio components repsponsible for those settings"""
4751

4852
tab_names = []
@@ -65,9 +69,9 @@
6569

6670
gradio_theme = gr.themes.Base()
6771

68-
total_tqdm = None
72+
total_tqdm: 'shared_total_tqdm.TotalTQDM' = None
6973

70-
mem_mon = None
74+
mem_mon: 'memmon.MemUsageMonitor' = None
7175

7276
options_section = options.options_section
7377
OptionInfo = options.OptionInfo

0 commit comments

Comments
 (0)