-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Initial idlelib stubs #9193
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
Initial idlelib stubs #9193
Conversation
This comment has been minimized.
This comment has been minimized.
Hi! Are these stubs for the stdlib Also, can I ask what your use case is for these stubs? I think |
I also think that the initial exception of You did a massive (and great) work of annotating this package, but I think it was worth discussing first :( |
It doesn't seem like we've discussed including idlelib in much detail; I only found this comment from @Akuli: #1019 (comment). I wouldn't necessarily be opposed to adding stubs for idlelib if it's useful for users, but it's definitely a serious maintenance risk. |
I've found it useful for writing IDLE extensions, which was really the main reason I started working on them. Sorry I hadn't discussed it first, I was reading mypy's documentation about stub files to start this. @AlexWaygood What would be best to go about changing what directory things should go to? Remove from this one and transfer to |
Yeah, just move them from one directory to another and commit it -- no need to make a new pull request :) You don't need to worry about git history in a typeshed PR; it'll all be squash-merged in the end anyway. |
This comment has been minimized.
This comment has been minimized.
I fixed a few easy-to-fix blocking things (adding it to VERSIONS, etc.), but before we go any further we need to decide if it's a good idea to accept these stubs. Personally: I'd vote "no". The PEP 434 exemption from backwards compatibility scares me. I don't like the idea of stubtest suddenly failing in CI for every patch release of CPython because of idlelib feature backports. But I'd like to hear the opinions of other maintainers :) |
This comment has been minimized.
This comment has been minimized.
Pinging @terryjreedy as the maintainer of IDLE (not asking for any work from you in terms of reviewing these stubs, but curious to hear your thoughts). As I see it the main arguments in favor of including idlelib stubs in typeshed are:
And the main arguments against are:
|
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.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I have never used static typing and have not previous seen non-toy stub files and have little idea of the different types of stub file tests. But I have followed some of the discussion of typing syntax in .py files. Some types of 'foreign' code using idlelib:
I could imagine using this myself for refactoring or other idlelib code improvements. But it is not complete, clear, nor correct.
@classmethod
def reload(cls):
cls.popupwait = idleConf.GetOption(
"extensions", "AutoComplete", "popupwait", type="int", default=0) popupwait, an int, is not in the stub, but it is used in a call within another method. (A bug is the stubmaker?)
In looking at corresponding code, I noticed that some None defaults ( I am not sure that the potential benefit is worth the effort needed to squash the numerous remaining errors. |
Thanks @terryjreedy for chiming in, that's helpful! I'll just respond to two of the points that you made above:
Yes, this is intentional. Stub files are useful for many purposes -- they can often serve as documentation for a human reader. But the fundamental purpose of typeshed's stubs is a machine-readable format for a type checker. Imports that are not required for typing purposes are generally removed from the stub; if there are imports that are unnecessary for that purpose, our CI will fail.
Personally, I'm also not a massive fan of this idiom. However, PEP 484 states that imports in stub files should generally be considered "private to the stub" -- i.e., if a stub file |
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. 🤖🎉 |
Thanks for the PR, @CoolCat467, but I'm going to reject this, I'm afraid. I still think adding stubs for If you think these stubs will be useful for other people, you'll still be able to add stubs to PyPI as an Good luck! |
Ok, thank you for the information. |
A lot of files are complete, but a few big ones like
pyshell
are missing a lot. I hope this will be a helpful start to adding complete support for idlelib.