-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle forward references in a forward-compatible way #75
Conversation
apistrap/utils.py
Outdated
return eval(annotation, globs) | ||
|
||
|
||
def get_type_hints(function): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing param/return typehints & brief doc
apistrap/utils.py
Outdated
return globs | ||
|
||
|
||
def resolve_fw_decl(function, annotation, globs=None, level=0, search_stack_depth=2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing param/return typehints & brief doc
maybe rename to _resolve_fw_decl
?
apistrap/utils.py
Outdated
@@ -34,3 +36,33 @@ def snake_to_camel(value): | |||
""" | |||
result = "".join(x.capitalize() or "_" for x in value.split("_")) | |||
return result[0].lower() + result[1:] | |||
|
|||
|
|||
def get_function_perspective_globals(function, level=0, max_level=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing param/return typehints & brief doc
maybe rename to _get_function_perspective_globals
and leave without docs
return wrapper | ||
|
||
def _check_request_type(self, *args, **kwargs): | ||
if self._get_request_content_type(*args, **kwargs) != "application/json": | ||
raise ApiClientError("Unsupported media type, JSON is expected") | ||
|
||
def _process_request_kwargs(self, body, signature, request_arg, *args, **kwargs): | ||
def _process_request_kwargs(self, body, signature, request_arg: str, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing typehints for body
and signature
.. or are the too complicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our very first use of eval in apistrap... there is no way back I guess.
|
||
globs = get_function_perspective_globals(function) | ||
|
||
return eval(annotation, globs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoa
we can ignore the coverage |
@blazekadam Well, once (if?) Python implements looking up type annotations in |
No description provided.