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 types to net_util.py #4916

Merged
merged 1 commit into from
Jul 1, 2022
Merged

Conversation

tconkling
Copy link
Contributor

Drive-by type annotations before re-namespacing

@tconkling tconkling marked this pull request as ready for review July 1, 2022 16:50
@tconkling tconkling requested a review from a team July 1, 2022 16:50
@@ -92,17 +90,17 @@ def get_internal_ip():
return _internal_ip


def _make_blocking_http_get(url, timeout=5):
def _make_blocking_http_get(url: str, timeout: float = 5) -> Optional[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: not particularly important, but should this be written as 5.0 instead of 5 to emphasize that it's a float?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't hold this opinion strongly, but I think no. The type annotation is already there to tell you the type -- the reason to use a decimal in C-like languages is to prevent coercion-to-int in statements that would result in the loss of the decimal value, but I think that's not an issue in Python. (Like, 1/3 in Python results in a float even though both values are ints.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(That said, there may very well be some best practice I'm not aware of in which case my answer would change to "yes definitely!")

@tconkling tconkling merged commit 81db95c into streamlit:develop Jul 1, 2022
@tconkling tconkling deleted the tim/NetUtilTypes branch July 1, 2022 18:56
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.

None yet

2 participants