Skip to content

Commit

Permalink
Config/attribute access: return from initializing config if SPLConfig…
Browse files Browse the repository at this point in the history
… turns out to be None. Re #155.

After openConfig is called, SPLConfig would be something but Mypy assumes config will be None. Therefore to satisfy Mypy and to guard against this scenario, return from initializing ad-on config if SPLConfig does become None. At least this allows Studio app module to load, it may result in errors, which can be a clue to developers that soemthing odd must have happened with ConfigHub.
  • Loading branch information
josephsl committed Jan 27, 2021
1 parent 74def12 commit 07aff71
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addon/appModules/splstudio/splconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,11 @@ def initialize() -> None:
# 8.0: All this work will be performed when ConfigHub loads.
# #64 (18.07): performed by openConfig function.
openConfig("splstudio")
# #155 (21.03): Mypy will say that SPLConfig is None when in fact it is ready
# simply because openConfig function does not return SPLConfig.
# Therefore do a None guard check just to tell Mypy it is safe to proceed.
if SPLConfig is None:
return
# Locate instant profile and do something otherwise.
if SPLConfig.instantSwitch is not None and SPLConfig.instantSwitch not in SPLConfig.profileNames:
log.debug("SPL: failed to locate instant switch profile")
Expand Down

0 comments on commit 07aff71

Please sign in to comment.