-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Fix mypy issues in openapi.py with missing dict and use of typedDict #1034
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from importlib import resources | ||
from inspect import Signature | ||
from pathlib import Path | ||
from typing import Any, Callable, Dict, List, Optional, Tuple, TypedDict | ||
from typing import Any, Callable, Dict, List, Optional, Tuple | ||
|
||
from robyn.responses import html | ||
from robyn.robyn import QueryParams, Response | ||
|
@@ -236,9 +236,9 @@ def get_path_obj( | |
name: str, | ||
description: str, | ||
tags: List[str], | ||
query_params: Optional[TypedDict], | ||
request_body: Optional[TypedDict], | ||
return_annotation: Optional[TypedDict], | ||
query_params: Optional[Dict], | ||
request_body: Optional[Dict], | ||
return_annotation: Optional[Dict], | ||
) -> Tuple[str, dict]: | ||
""" | ||
Get the "path" openapi object according to spec | ||
|
@@ -258,7 +258,7 @@ def get_path_obj( | |
if not description: | ||
description = "No description provided" | ||
|
||
openapi_path_object = { | ||
openapi_path_object: dict = { | ||
"summary": name, | ||
"description": description, | ||
"parameters": [], | ||
|
@@ -293,7 +293,7 @@ def get_path_obj( | |
endpoint_with_path_params_wrapped_in_braces += "/{" + path_param_name + "}" | ||
|
||
if query_params: | ||
query_param_annotations = query_params.__annotations__ if query_params is TypedDict else typing.get_type_hints(query_params) | ||
query_param_annotations = query_params.__annotations__ if query_params is Dict else typing.get_type_hints(query_params) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these functions wouldn't make sense on a regular dict. |
||
|
||
for query_param in query_param_annotations: | ||
query_param_type = self.get_openapi_type(query_param_annotations[query_param]) | ||
|
@@ -310,7 +310,7 @@ def get_path_obj( | |
if request_body: | ||
properties = {} | ||
|
||
request_body_annotations = request_body.__annotations__ if request_body is TypedDict else typing.get_type_hints(request_body) | ||
request_body_annotations = request_body.__annotations__ if request_body is Dict else typing.get_type_hints(request_body) | ||
|
||
for body_item in request_body_annotations: | ||
properties[body_item] = self.get_schema_object(body_item, request_body_annotations[body_item]) | ||
|
@@ -339,7 +339,7 @@ def get_path_obj( | |
|
||
return endpoint_with_path_params_wrapped_in_braces, openapi_path_object | ||
|
||
def get_openapi_type(self, typed_dict: TypedDict) -> str: | ||
def get_openapi_type(self, typed_dict: Dict) -> str: | ||
""" | ||
Get actual type from the TypedDict annotations | ||
|
||
|
@@ -371,7 +371,7 @@ def get_schema_object(self, parameter: str, param_type: Any) -> dict: | |
@return: dict the properties object | ||
""" | ||
|
||
properties = { | ||
properties: dict = { | ||
"title": parameter.capitalize(), | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What error prompted these changes??
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.
I'll check tomorrow.
I think the solution (to follow all the docs I can find) would be to have our own class of TypedDict rather than use TypedDict directly.