Fix weird (C based?) functions without __annotations__.
Creating such functions using just Python didn't succeed so couldn't
create tests.
Fixes
@@ -68,10 +68,14 @@ class PythonArgumentParser:
try:
type_hints = typing.get_type_hints(handler)
except Exception: # Can raise pretty much anything
- return handler.__annotations__
+ # Handle weird (C based?) functions without annotations.
+ # https://github.com/robotframework/robotframework/issues/4059
+ return getattr(handler, '__annotations__', {})
self._remove_mismatching_type_hints(type_hints, spec.argument_names)
return type_hints
+ # TODO: This is likely not needed nowadays because we unwrap keywords.
+ # Don't want to remove in 4.1.x but can go in 5.0.
def _remove_mismatching_type_hints(self, type_hints, argument_names):
# typing.get_type_hints returns info from the original function even
# if it is decorated. Argument names are got from the wrapping
