Skip to content

Commit 8808f7c

Browse files
committed
Improve autostart() input typing
1 parent a7c098c commit 8808f7c

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

aw_qt/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import logging
33
import argparse
4-
from typing import Set
4+
from typing import List
55
from typing_extensions import TypedDict
66

77
from aw_core.log import setup_logging
@@ -25,7 +25,7 @@ def main() -> None:
2525
sys.exit(error_code)
2626

2727

28-
CommandLineArgs = TypedDict('CommandLineArgs', {'testing': bool, 'autostart_modules': Set[str]}, total=False)
28+
CommandLineArgs = TypedDict('CommandLineArgs', {'testing': bool, 'autostart_modules': List[str]}, total=False)
2929

3030

3131
def parse_args() -> CommandLineArgs:

aw_qt/manager.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,23 @@ def start(self, module_name: str) -> None:
209209
else:
210210
logger.debug("Manager tried to start nonexistent module {}".format(module_name))
211211

212-
def autostart(self, autostart_modules: Optional[Set[str]]) -> None:
212+
def autostart(self, autostart_modules: Optional[List[str]]) -> None:
213213
if autostart_modules is None:
214-
autostart_modules = set()
214+
autostart_modules = []
215215
if len(autostart_modules) > 0:
216216
logger.info("Modules to start weren't specified in CLI arguments. Falling back to configuration.")
217-
autostart_modules = set(self.settings.autostart_modules)
218-
217+
autostart_modules = self.settings.autostart_modules
219218
# We only want to autostart modules that are both in found modules and are asked to autostart.
220-
autostart_modules = autostart_modules.intersection(set(self.modules.keys()))
221-
# Always start aw-server first
222-
if "aw-server" in autostart_modules:
223-
self.start("aw-server")
224-
elif "aw-server-rust" in autostart_modules:
219+
modules_to_start = set(autostart_modules).intersection(set(self.modules.keys()))
220+
221+
# Start aw-server-rust first
222+
if "aw-server-rust" in modules_to_start:
225223
self.start("aw-server-rust")
224+
elif "aw-server" in modules_to_start:
225+
self.start("aw-server")
226226

227-
autostart_modules = set(autostart_modules) - {"aw-server", "aw-server-rust"}
228-
for module_name in autostart_modules:
227+
modules_to_start = set(autostart_modules) - {"aw-server", "aw-server-rust"}
228+
for module_name in modules_to_start:
229229
self.start(module_name)
230230

231231
def stop_all(self) -> None:

0 commit comments

Comments
 (0)