Title: `socket.socketpair`'s `type` parameter accepts `SocketType` on non-Windows · Issue #15283 · python/typeshed · GitHub
Open Graph Title: `socket.socketpair`'s `type` parameter accepts `SocketType` on non-Windows · Issue #15283 · python/typeshed
X Title: `socket.socketpair`'s `type` parameter accepts `SocketType` on non-Windows · Issue #15283 · python/typeshed
Description: socket.socketpair's type parameter on non-Windows platforms is annotated SocketType | int: typeshed/stdlib/socket.pyi Lines 1411 to 1413 in cd8b26b def socketpair( family: int | AddressFamily | None = None, type: SocketType | int = ..., ...
Open Graph Description: socket.socketpair's type parameter on non-Windows platforms is annotated SocketType | int: typeshed/stdlib/socket.pyi Lines 1411 to 1413 in cd8b26b def socketpair( family: int | AddressFamily | Non...
X Description: socket.socketpair's type parameter on non-Windows platforms is annotated SocketType | int: typeshed/stdlib/socket.pyi Lines 1411 to 1413 in cd8b26b def socketpair( family: int | AddressFamily |...
Opengraph URL: https://github.com/python/typeshed/issues/15283
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`socket.socketpair`'s `type` parameter accepts `SocketType` on non-Windows","articleBody":"`socket.socketpair`'s `type` parameter on non-Windows platforms is annotated `SocketType | int`:\n\nhttps://github.com/python/typeshed/blob/cd8b26b0ceef26cd84ab614088140d48680ac7f7/stdlib/socket.pyi#L1411-L1413\n\nIt seems like it should be `SocketKind | int`, similar to the `type` parameter of `socket.socket` and `socket.fromfd`:\n\nhttps://github.com/python/typeshed/blob/cd8b26b0ceef26cd84ab614088140d48680ac7f7/stdlib/socket.pyi#L1319-L1321\n\nhttps://github.com/python/typeshed/blob/cd8b26b0ceef26cd84ab614088140d48680ac7f7/stdlib/socket.pyi#L1396\n\nPassing a `SocketKind` (e.g. `socket.socketpair(type=SocketKind.SOCK_STREAM)`) already works fine since `SocketKind` is an `int` subtype. I don't think that `SocketType` is supported though. There don't appear to be any paths in CPython where a `SocketType` is accepted; the only two paths are\n\n* Pass the `type: SocketType` to `socket.socket`: https://github.com/python/cpython/blob/v3.14.2/Lib/socket.py#L659-L668, which blows up:\n\n ```\n Traceback (most recent call last):\n File \"/tmp/tmp.SPNfuStkPY/eg.py\", line 3, in \u003cmodule\u003e\n socketlib.socketpair(type=socketlib.socket())\n ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/ganden/.pyenv/versions/3.13/lib/python3.13/socket.py\", line 659, in socketpair\n a, b = _socket.socketpair(family, type, proto)\n ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^\n TypeError: 'socket' object cannot be interpreted as an integer\n ```\n\n* Or blow up if `type` is anything but `SocketKind.SOCK_STREAM`:\n\n https://github.com/python/cpython/blob/v3.14.2/Lib/socket.py#L604-L613","author":{"url":"https://github.com/gschaffner","@type":"Person","name":"gschaffner"},"datePublished":"2026-01-15T06:15:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/15283/typeshed/issues/15283"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bab42955-2946-2c69-11f7-46b57c1c4d94 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D83E:FA21D:3485A0:4A851C:6A632237 |
| html-safe-nonce | fac36a3a35cd000b726a62411e51b988f5213598bd32ec148a23dfdcfe2a8267 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODNFOkZBMjFEOjM0ODVBMDo0QTg1MUM6NkE2MzIyMzciLCJ2aXNpdG9yX2lkIjoiNDM1NDQ1ODE0ODIyNzE5NTQ0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e1fd8be56163f0241d979a6072c0f516d5ab8721324b0f900538e1155e8e98ca |
| hovercard-subject-tag | issue:3816162988 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/15283/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d04cf795fbcff5e53632232b6ce0a86de82cffe21aa2ec52b7b6795d9a04b6eb/python/typeshed/issues/15283 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d04cf795fbcff5e53632232b6ce0a86de82cffe21aa2ec52b7b6795d9a04b6eb/python/typeshed/issues/15283 |
| og:image:alt | socket.socketpair's type parameter on non-Windows platforms is annotated SocketType | int: typeshed/stdlib/socket.pyi Lines 1411 to 1413 in cd8b26b def socketpair( family: int | AddressFamily | Non... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gschaffner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1a6c056e02f174fffc096c521ec0ff6fb83e40a2ec8cb8875466ec1524872dd6 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6a93e25585f487ddff9e3996c06d5b869d6e1828 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width