Uh oh!
There was an error while loading. Please reload this page.
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.
AlexWaygood
commented
Oct 15, 2023
Ugh. This whole " >>> import sys
>>> sys.monitoring
<module 'sys.monitoring'>
>>> import types
>>> type(sys.monitoring) is types.ModuleType
TrueStubtest special-cases We may have to add some special-casing for |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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>
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood
left a comment
There was a problem hiding this comment.
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. 🤖🎉 |
lancelote
commented
Oct 16, 2023
@AlexWaygood Thank you for your time reviewing the PR 🙇 |
nedbat
commented
Nov 29, 2023
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? |
AlexWaygood
commented
Nov 29, 2023
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 |
nedbat
commented
Nov 29, 2023
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... |
AlexWaygood
commented
Nov 29, 2023
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 :-) |
AlexWaygood
commented
Nov 29, 2023
Tagging @hauntsaninja, though, as a mypy/typeshed maintainer who has cut mypy patch releases in the past :-) |
JelleZijlstra
commented
Nov 29, 2023
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. |
nedbat
commented
Nov 29, 2023
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? |
JelleZijlstra
commented
Nov 29, 2023
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 |
hauntsaninja
commented
Nov 29, 2023
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. |
AlexWaygood
commented
Nov 29, 2023
|
AlexWaygood
commented
Dec 21, 2023
@nedbat, mypy 1.8 has now been released, which includes these stubs :) |
Type annotations for
sys.monitoringintroduced by python/cpython#103082 (PEP 669) in Python 3.12.I am not entirely sure my approach is correct as
sys.monitoringis a namespace. I refactoredsysmodule into a package,_monitoring.pyiis then imported insidesys/__init__.py. Will appreciate any feedback on it 🙇