more limited jank fix
This commit is contained in:
parent
c2a9726ec6
commit
98d3967dfe
2 changed files with 2 additions and 3 deletions
|
@ -42,7 +42,7 @@ def main():
|
|||
|
||||
for addon in addons:
|
||||
help_text += f"\n {addon.__name__} \t{addon.__doc__ or ''}"
|
||||
cfg_clazz = get_type_hints(addon, globalns=globals())['config']
|
||||
cfg_clazz = get_type_hints(addon, localns={'Treepuncher':Treepuncher})['config']
|
||||
if cfg_clazz is ConfigObject:
|
||||
continue # it's the superclass type hint
|
||||
for field in fields(cfg_clazz):
|
||||
|
|
|
@ -58,11 +58,10 @@ class Addon:
|
|||
self.name = type(self).__name__
|
||||
cfg = self._client.config
|
||||
opts: Dict[str, Any] = {}
|
||||
localns = { 'Treepuncher': None } # TODO jank fix!
|
||||
# get_type_hints attempts to instantiate all string hints (such as 'Treepuncher').
|
||||
# But we can't import Treepuncher here: would be a cyclic import!
|
||||
# We don't care about Treepuncher annotation, so we force it to be None
|
||||
cfg_clazz = get_type_hints(type(self), globalns=globals(), localns=localns)['config']
|
||||
cfg_clazz = get_type_hints(type(self), localns={'Treepuncher': None})['config'] # TODO jank localns override
|
||||
if cfg_clazz is not ConfigObject:
|
||||
for field in fields(cfg_clazz):
|
||||
default = field.default if field.default is not MISSING \
|
||||
|
|
Loading…
Reference in a new issue