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

Add return type hints #1371

Closed
wants to merge 3 commits into from
Closed

Add return type hints #1371

wants to merge 3 commits into from

Conversation

gzpcho
Copy link
Contributor

@gzpcho gzpcho commented Dec 8, 2023

No description provided.

@gzpcho gzpcho requested a review from a team as a code owner December 8, 2023 22:40
@gzpcho gzpcho marked this pull request as draft December 11, 2023 17:00
@gzpcho gzpcho marked this pull request as ready for review December 14, 2023 23:03
Copy link
Contributor

@ntascii ntascii left a 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?

@gzpcho
Copy link
Contributor Author

gzpcho commented Jan 9, 2024

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]:
Copy link
Contributor

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?

Copy link
Contributor Author

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:
Copy link
Contributor

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?

Copy link
Contributor Author

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

@gzpcho
Copy link
Contributor Author

gzpcho commented Jan 16, 2024

Will split this PR into smaller ones for easier and safer rollout

@gzpcho
Copy link
Contributor Author

gzpcho commented Jan 19, 2024

Split up into the following PRs:
#1403
#1404
#1405
#1406

@gzpcho gzpcho closed this Jan 19, 2024
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.

2 participants