-
-
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
stubtest: disable --ignore-missing-stubs for stdlib? #6401
Comments
Yes, let's do it. |
Here's my analysis of which modules are missing the most classes/functions/methods/constants, according to stubtest: Counter({
'distutils': 165, 'xml': 69, 'tkinter': 51, 'email': 45, 'multiprocessing': 30, '__main__': 27, 'asyncio': 17,
'os': 17, 'importlib': 15, 'cgi': 11, 'profile': 11, '_thread': 10, 'pkgutil': 10, 'codecs': 8, 'sre_constants': 8,
'logging': 7, 'ssl': 7, '_collections_abc': 5, 'wsgiref': 5, '_markupbase': 4, '_winapi': 4, 'ctypes': 4, 'types': 4,
'asynchat': 3, 'pipes': 3, 'pstats': 3, 'pydoc': 3, 'socket': 3, 'threading': 3, 'turtle': 3, '_csv': 2, '_threading_local': 2,
'ast': 2, 'asyncore': 2, 'builtins': 2, 'configparser': 2, ' setup': 2, '': 2, 'inspect': 2, 'lib2to3': 2, 'msvcrt': 2, 'pickle': 2,
'pyexpat': 2, 'rlcompleter': 2, 'signal': 2, 'sunau': 2, 'symtable': 2, 'unittest': 2, 'wave': 2, 'zipimport': 2, '_ast': 1,
'_codecs': 1, '_imp': 1, '_json': 1, '_msi': 1, '_weakref': 1, 'bdb': 1, 'bz2': 1, 'csv': 1, 'ftplib': 1, 'hmac': 1, 'mimetypes': 1,
'modulefinder': 1, 'platform': 1, 'random': 1, 're': 1, 'sched': 1, 'socketserver': 1, 'subprocess': 1, 'token': 1,
'tokenize': 1, 'tracemalloc': 1, 'typing': 1, 'unicodedata': 1, 'weakref': 1, 'winreg': 1
}) As you can see, it should be pretty manageable to disable A summary list of all classes that stubtest reports is missing is attached |
It might also be good if we could suppress stubtest for any names starting with a single underscore, as those are often private/ uncommented/implementation details |
Here's the equivalent analysis of all missing objects, excluding objects that have names starting with a single leading underscore: Counter({
'distutils': 165, 'xml': 69, 'tkinter': 51, 'email': 45, 'multiprocessing': 30, '__main__': 27, 'os': 17, 'importlib': 15,
'asyncio': 13, 'cgi': 11, 'profile': 11, 'pkgutil': 10, 'codecs': 8, 'sre_constants': 8, '_thread': 7, 'logging': 7, 'ssl': 7,
'_collections_abc': 5, 'wsgiref': 5, '_markupbase': 4, '_winapi': 4, 'ctypes': 4, 'types': 4, 'asynchat': 3, 'pipes': 3,
'pstats': 3, 'pydoc': 3, 'socket': 3, 'threading': 3, 'turtle': 3, '_csv': 2, 'ast': 2, 'asyncore': 2, 'builtins': 2, 'configparser': 2,
' setup': 2, 'inspect': 2, 'lib2to3': 2, 'msvcrt': 2, 'pickle': 2, 'pyexpat': 2, 'rlcompleter': 2, 'signal': 2, 'sunau': 2,
'symtable': 2, 'unittest': 2, 'wave': 2, 'zipimport': 2, '_ast': 1, '_codecs': 1, '_imp': 1, '_json': 1, '_msi': 1, '_weakref': 1,
'bdb': 1, 'bz2': 1, 'csv': 1, 'ftplib': 1, 'hmac': 1, 'mimetypes': 1, 'modulefinder': 1, 'platform': 1, 'random': 1, 're': 1,
'sched': 1, 'socketserver': 1, 'subprocess': 1, 'token': 1, 'tokenize': 1, 'tracemalloc': 1, 'unicodedata': 1, 'weakref': 1
'winreg': 1
}) |
We have auto-updating of stdlib allowlists, which we didn't have when I first added stubtest, so doing this is more convenient for contributors than it would have been. I will say I'm still a little concerned about the "false negatives in new additions" problem. If stubtest has ever caught an issue for you when adding something to a stdlib, it likely no longer will. Also maybe useful to know if we decide to go ahead here is the stubtest @AlexWaygood stubtest has some heuristics for deciding what to check, and leading single underscore is among them. I think I've fixed some issues in mypy's public name detection since 0.910, but I'd be curious where you think heuristics are failing. |
If I understood correctly, this isn't a problem if we add stubgen-generated stubs very soon after disabling |
I've just been using the version of stubtest in typeshed's repo, so it may be that the issue's already been fixed! I'll try and double-check. But here are some of the names starting with a leading underscore that stubtest was flagging for me:
|
Here are all of them (
Edit: changed command to remove duplicates from output |
For the |
There are some interesting false-positives in I imagine there's not an easy fix here, since it's just a fact that Python's |
Yeah, there are a couple cases like that... the module I remember is |
Getting slightly off-topic, but I also noticed that stubtest has some false negatives when finding primitive objects missing in stubs that are missing After fixing this, we find several more module level constants. We also find a few more loops: Here's the diff, python/mypy#11634, I recommend using it to find missing stubs cc @AlexWaygood |
Do we care about the flags stubtest is raising for |
In any case, we can add the classes to allowlists for now and revisit them later if needed. |
I'd avoid changing too much related to |
FWIW I've basically added all the objects from the list that I feel comfortable adding (until I get my hands on @hauntsaninja's longer list). The remaining missing objects are either (1) false positives; (2) platform-specific; (3) deprecated; or (4) in modules I don't know enough about to be confident writing a PR for. |
@AlexWaygood has recently fixed lots of things in the standard library by running
stubtest_stdlib
without the--ignore-missing-stubs
option. Maybe our CI should do that too, so that we notice what's missing? This doesn't apply to third-party stubs very well, because then our CI would be broken every time a new feature is added to any library, but the standard library is relatively stable.The text was updated successfully, but these errors were encountered: