-
-
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 sys.monitoring
from Python 3.12
#10890
Conversation
Thanks! I think this is probably the right approach. We already do something similar with (Unlike |
This comment has been minimized.
This comment has been minimized.
Ugh. This whole " >>> import sys
>>> sys.monitoring
<module 'sys.monitoring'>
>>> import types
>>> type(sys.monitoring) is types.ModuleType
True Stubtest special-cases We may have to add some special-casing for |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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! I'll push a change to fixup a few comments, and then merge :D
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
@AlexWaygood Thank you for your time reviewing the PR 🙇 |
I would like to use these stubs, but they are not in 1.7.1. When might they be available in a mypy release, or how can I use the stub files locally in my project? |
Hi @nedbat! These stubs have already been added to the mypy In the meantime, if you want to use the stub files locally in your project, you can clone typeshed, and use mypy's |
Is a 1.7.2 unheard-of? :hope: Locally cloning typeshed is a possibility, but I would need to do that for CI also, and it starts to get involved... |
You could try asking at python/mypy#16341 if you could have a mypy patch release cherry-picking the stubs for Anyway, that's not really something we have control over here at typeshed -- you'd have to make the request over at mypy :-) |
Tagging @hauntsaninja, though, as a mypy/typeshed maintainer who has cut mypy patch releases in the past :-) |
We also don't generally update typeshed in mypy bugfix releases: those releases are meant to fix regressions and crashes, not to introduce new updates or fix already-existing bugs. |
Maybe this deserves a completely different thread, but: what is the policy about updating stdlib stubs? The pull request that added sys.monitoring was merged in April. Should we expect updated stubs as part of stdlib work? |
There is no expectation that people who contribute to CPython also contribute typeshed stubs. We generally add them as we notice them, or as people ask for them. I'm personally hesitant to reflect changes in the CPython main branch to typeshed very quickly, because the code often ends up changing before it makes it into a release, creating more churn for us. |
In general, we start working on reflecting additions to the stdlib as soon as the beta period starts; most new stdlib modules are generally added in typeshed well before they're available at runtime in a non-beta release of CPython. For this module in particular, we didn't notice it was missing until after 3.12.0 was released, because our tests didn't pick up that it was missing. Our tests missed that it was missing because of the unique way that |
My total guess is it would be a few months before 1.8, so if someone cherry picked just this change to the mypy 1.7 branch, I'd be willing to cut a 1.7.2. |
|
@nedbat, mypy 1.8 has now been released, which includes these stubs :) |
Type annotations for
sys.monitoring
introduced by python/cpython#103082 (PEP 669) in Python 3.12.I am not entirely sure my approach is correct as
sys.monitoring
is a namespace. I refactoredsys
module into a package,_monitoring.pyi
is then imported insidesys/__init__.py
. Will appreciate any feedback on it 🙇