-
Notifications
You must be signed in to change notification settings - Fork 48
fix __new__
typing for OpenApiModel
#2433
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 __new__
typing for OpenApiModel
#2433
Conversation
__new__
typing for OpenApiModel
@@ -173,6 +173,18 @@ class OpenApiModel(object): | |||
"""Get the value of an attribute using dot notation: `instance.attr`.""" | |||
return self.__getitem__(attr) | |||
|
|||
@overload | |||
def __new__(cls, arg: None) -> 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.
Is there a difference between this as pass
?
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.
nope! ...
(or the singleton Ellipsis
) in python is just a convention used to indicate that it is not the real implementation, whereas pass
is usually used when the implementation is intentionally blank (like with try: ... except: pass
)
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.
tldr they both do nothing, but conventionally you would use ellipses for overload signature bodies
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.
The docs for overload also use ...
in their example usage.
/merge |
View all feedbacks in Devflow UI.
This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
[email protected] unqueued this merge request |
/merge -c |
View all feedbacks in Devflow UI. |
/merge |
View all feedbacks in Devflow UI.
This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
devflow unqueued this merge request: It did not become mergeable within the expected time |
9a34c24
to
4745276
Compare
@@ -173,6 +173,18 @@ class OpenApiModel(object): | |||
"""Get the value of an attribute using dot notation: `instance.attr`.""" | |||
return self.__getitem__(attr) | |||
|
|||
@overload | |||
def __new__(cls, arg: None) -> None: # type: ignore |
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.
had to add the type ignore because mypy (in CI) doesn't like this, but we do this in the code already, we just didn't reflect that in the typing before
What does this PR do?
Fixes the typing on


__new__
and makes constructors typing behave properly.before:
after:
Additional Notes
Review checklist
Please check relevant items below:
This PR includes all newly recorded cassettes for any modified tests.
This PR does not rely on API client schema changes.
Or, this PR relies on API schema changes and this is a Draft PR to include tests for that new functionality.