Skip to content
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

Merged
merged 2 commits into from
Aug 13, 2019

Conversation

janbuchar
Copy link
Collaborator

No description provided.

@janbuchar janbuchar requested a review from blazekadam June 27, 2019 12:55
return eval(annotation, globs)


def get_type_hints(function):
Copy link
Member

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

return globs


def resolve_fw_decl(function, annotation, globs=None, level=0, search_stack_depth=2):
Copy link
Member

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?

@@ -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):
Copy link
Member

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):
Copy link
Member

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?

@janbuchar janbuchar requested a review from petrbel July 29, 2019 15:07
@janbuchar janbuchar mentioned this pull request Aug 7, 2019
Copy link
Contributor

@blazekadam blazekadam left a 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa

@blazekadam
Copy link
Contributor

we can ignore the coverage

@janbuchar
Copy link
Collaborator Author

@blazekadam Well, once (if?) Python implements looking up type annotations in inspect, we can remove this again.

@janbuchar janbuchar merged commit 8d21355 into dev Aug 13, 2019
@janbuchar janbuchar deleted the better-annotation-processing branch August 13, 2019 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants