-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 missing ETH_P_ALL
identifier to socket
#11876
Conversation
This comment has been minimized.
This comment has been minimized.
Unfortunately, only simple platform checks using |
For reference, https://typing.readthedocs.io/en/latest/source/stubs.html#version-and-platform-checks documents the currently supported formats. I've also opened python/typing#1732, suggesting to add |
Understood. For now, I'll just add in those missing FreeBSD identifiers using the current platform check syntax with a comment identifying them as FreeBSD constants. |
@@ -525,6 +532,9 @@ class AddressFamily(IntEnum): | |||
AF_BLUETOOTH = 32 | |||
if sys.platform == "win32" and sys.version_info >= (3, 12): | |||
AF_HYPERV = 34 | |||
if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin" and sys.version_info >= (3, 12): |
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.
If preferred, can also do this as
if sys.version_info >= (3, 12):
if sys.platform == "win32":
AF_HYPERV = 34
if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
# FreeBSD >= 14.0
AF_DIVERT = 44
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
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.
Thanks!
It seems #10247/#11219 missed a couple identifiers in the
socket
stub (the_socket
stub seems good, though). This PR addssocket.ETH_P_ALL
(https://docs.python.org/3/library/socket.html#socket.ETH_P_ALL).There's also
AF_DIVERT
andPF_DIVERT
missing from thesocket
stub, as well, but I've omitted those from this PR for a couple reasons. These are only available on FreeBSD systems, which was correctly noted in the comment above their type annotations in_socket
, but the condition to check for this availability is (or at least seems to be) logically incorrect:The
sys.platform
documentation shows the correct (or at least a more correct) conditional statement:And similarly for the
socket
stub:All this essentially to ask if the current check (
sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin"
) is just how typeshed has decided to check for FreeBSD systems, or if it would be preferable to use thesys.platform.startswith('freebsd')
check. And, if this would be preferred, should parsing and checking the version be included, as well?I also don't have a FreeBSD system to personally test with, so wasn't sure if I should let someone on an actual FreeBSD 14 system handle this (although, I suppose it wouldn't be too much trouble to spin up a FreeBSD VM if necessary).