-
Notifications
You must be signed in to change notification settings - Fork 250
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
Add return type hints #1371
Add return type hints #1371
Conversation
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.
how did you get the right types? any way we can automate?
A lot of manual inspection 😅 Only way we could maybe automate is if deploy-agent supported some non-containerized runtime that maybe we could run some existing analysis tool on. I have another PR in-progress for adding types to class members too. |
@@ -455,7 +458,7 @@ def _update_deploy_alias(self, deploy_goal): | |||
deploy_goal.envName)) | |||
|
|||
@staticmethod | |||
def plan_changed(old_response, new_response): | |||
def plan_changed(old_response, new_response) -> Union[PingResponse, bool, DeployGoal]: |
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.
this might be a signal that we need to refactor the code to have a single return type. Btw, can we use PingResponse | bool | DeployGoal
?
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.
Agreed to your first point. That syntax is only supported in python 3.10 and above. https://peps.python.org/pep-0604/
@@ -59,7 +60,7 @@ def get_build_id(filename, env_name): | |||
return False, None | |||
|
|||
@staticmethod | |||
def get_stale_builds(build_timestamps, num_builds_to_retain=2): | |||
def get_stale_builds(build_timestamps, num_builds_to_retain=2) -> Generator: |
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.
why the type is generator?
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.
This is a generator function since it calls the yield
keyword. https://stackoverflow.com/questions/43658999/what-is-the-return-type-hint-of-a-generator-function
Will split this PR into smaller ones for easier and safer rollout |
No description provided.