-
-
Notifications
You must be signed in to change notification settings - Fork 717
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
Improve get_ip_interface error message when interface does not exist #2964
Improve get_ip_interface error message when interface does not exist #2964
Conversation
distributed/tests/test_utils.py
Outdated
expected_error_message += ".+'lo0'" | ||
elif sys.platform.startswith("linux"): | ||
expected_error_message += ".+'lo'" | ||
with pytest.raises(KeyError, match=expected_error_message): |
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.
Small nit:
Rather than test that the entire error message is exactly this, we might instead test some properties of it that we care about, like that "network interface" and the names of other interfaces are present in the message.
If someone changes the error message but includes this kind of information I think that that's ok, and shouldn't be considered an error.
raise KeyError( | ||
"{!r} is not a valid network interface. " | ||
"Valid network interfaces are: {}".format(ifname, allowed_ifnames) | ||
) |
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 great. I really like changes like this!
Thanks for this change @lesteve ! I left one small nit, but I'm totally fine with this PR as-is. I'm fine with changing the error type if you prefer. |
I pushed a commit:
|
Thanks @lesteve ! |
Context: in
dask-jobqueue
you need some tweaking to find the right network interface to use on your cluster. People may not be familiar with what a network interface is and the current error message is a bit cryptic.The main thing I am wondering about is whether we should keep the same error type
KeyError
with backward-compatibility in mind or switch toValueError
sinceValueError
is already the type of the error you get when the network interface does not have a valid IPv4 address.My personal preference would be to switch to
ValueError
but I have keptKeyError
for now.Error message on master:
Error message in this PR: