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

chore: Remove unreachable return statements #17622

Merged
merged 2 commits into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions superset/utils/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ def is_port_open(host: str, port: int) -> bool:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(PORT_TIMEOUT)
try:
s.connect((host, int(port)))
s.connect((host, port))
s.shutdown(socket.SHUT_RDWR)
return True
except socket.error:
return False
finally:
s.close()

return False
Copy link
Member

Choose a reason for hiding this comment

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

bycatch: I notice that port is an int in the argument list, but we're recasting it to int on line 33, which is unnecessary. While we're at it, I'd almost recommend removing that cast, and make sure code ever calls this function with anything except an int value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot; I have taken out the int cast - by the looks of it, is_port_open() is only used here, where port is indeed an integer.



def is_hostname_valid(host: str) -> bool:
"""
Expand All @@ -51,8 +49,6 @@ def is_hostname_valid(host: str) -> bool:
except socket.gaierror:
return False

return False


def is_host_up(host: str) -> bool:
"""
Expand Down