jank fix for 'Treepuncher' type hint

This commit is contained in:
əlemi 2022-04-28 13:44:17 +02:00
parent 757be795c3
commit c29a03aeda
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

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