fix: lookup types with globalns

This commit is contained in:
əlemi 2022-04-28 13:18:18 +02:00
parent 8b9848cdfb
commit 757be795c3
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E
3 changed files with 4 additions and 4 deletions

View file

@ -42,7 +42,7 @@ def main():
for addon in addons: for addon in addons:
help_text += f"\n {addon.__name__} \t{addon.__doc__ or ''}" help_text += f"\n {addon.__name__} \t{addon.__doc__ or ''}"
cfg_clazz = get_type_hints(addon)['config'] cfg_clazz = get_type_hints(addon, globalns=globals())['config']
if cfg_clazz is ConfigObject: if cfg_clazz is ConfigObject:
continue # it's the superclass type hint continue # it's the superclass type hint
for field in fields(cfg_clazz): for field in fields(cfg_clazz):

View file

@ -58,7 +58,7 @@ class Addon:
self.name = type(self).__name__ self.name = type(self).__name__
cfg = self._client.config cfg = self._client.config
opts: Dict[str, Any] = {} opts: Dict[str, Any] = {}
cfg_clazz = get_type_hints(type(self))['config'] cfg_clazz = get_type_hints(type(self), globalns=globals())['config']
if cfg_clazz is not ConfigObject: if cfg_clazz is not ConfigObject:
for field in fields(cfg_clazz): for field in fields(cfg_clazz):
default = field.default if field.default is not MISSING \ default = field.default if field.default is not MISSING \

View file

@ -84,6 +84,8 @@ class Treepuncher(
code= opt('code'), code= opt('code'),
) )
super().__init__(opt('server', required=True), online_mode=online_mode, authenticator=authenticator)
self.storage = Storage(self.name) self.storage = Storage(self.name)
self.notifier = Notifier(self) self.notifier = Notifier(self)
@ -95,8 +97,6 @@ class Treepuncher(
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) # So it's way less spammy logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) # So it's way less spammy
self.scheduler.start(paused=True) self.scheduler.start(paused=True)
super().__init__(opt('server', required=True), online_mode=online_mode, authenticator=authenticator)
prev = self.storage.system() # if this isn't 1st time, this won't be None. Load token from there prev = self.storage.system() # if this isn't 1st time, this won't be None. Load token from there
state = SystemState(self.name, __VERSION__, 0) state = SystemState(self.name, __VERSION__, 0)
if prev: if prev: