🐛 Fix inject type hint forward references

This commit is contained in:
xtaodada 2024-08-13 21:03:29 +08:00
parent f75fb07f44
commit 988d51feaf
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -10,7 +10,8 @@ def inject(message: enums.Message, function, **data) -> Optional[Dict]:
except Exception: except Exception:
return None return None
for parameter_name, parameter in signature.parameters.items(): for parameter_name, parameter in signature.parameters.items():
class_name = parameter.annotation.__name__ an = parameter.annotation
class_name = an.__name__ if hasattr(an, "__name__") else an
param = message if class_name == "Message" else services.get(class_name) param = message if class_name == "Message" else services.get(class_name)
if not param: if not param:
if parameter_name == "message": if parameter_name == "message":