-
-
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
select.poll is not available on windows #13243
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
Hmm, this is messy. While >>> type(select.poll())
<class 'select.poll'> Plus the select docs document the methods on poll objects as though there is a class named |
Yeah, it's not the only case where that happens in the stdlib; mostly in older C modules. It's a tradeoff of accuracy versus ease of typing, and we've come down on both sides of that in typeshed depending on the situation. I was thinking that maybe the recommendation to use class SocketChecker:
def __init__(self) -> None:
self._poller: Optional[select.poll]
if _HAVE_POLL:
self._poller = select.poll()
else:
self._poller = None So we should probably keep this as a type. I suspect it's too niche to be worthwhile, but it'd be neat if we had a decorator to use on functions to indicate that if this function is used as a type, then the return type of the function is what's meant. We could resolve a dozen or so compromises in typeshed with something like that. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
It's also a function, but mypy-primer shows that it's in use as a type in the ecosystem, so I think we should keep that fiction.