Replace validate_stubs scripts with stubtest#371
Merged
debonte merged 23 commits intomicrosoft:mainfrom May 30, 2025
Merged
Conversation
c700e37 to
dbf819b
Compare
debonte
approved these changes
May 23, 2025
…into Replace-validate_stubs-scripts-with-stubtest
…into Replace-validate_stubs-scripts-with-stubtest
Contributor
Author
|
@debonte If you prefer, I can split off the changes to test across different Python versions |
Contributor
Contributor
Author
|
I think I'm through all the issues anyway ^^ |
…into Replace-validate_stubs-scripts-with-stubtest
This was referenced May 24, 2025
Contributor
Author
|
As this PR grows, I ended up splitting it off after all: #375 |
…into Replace-validate_stubs-scripts-with-stubtest
…into Replace-validate_stubs-scripts-with-stubtest
…into Replace-validate_stubs-scripts-with-stubtest
Avasam
commented
May 29, 2025
Comment on lines
+168
to
+169
| # follow_untyped_imports = true will cause stubtest to run mypy on the source | ||
| # So disable it for partial stubs |
Contributor
Author
There was a problem hiding this comment.
This doesn't feel like optimal behaviour for stubtest. I'll raise an issue upstream.
Avasam
commented
May 29, 2025
Comment on lines
+75
to
+81
| # This code is never run in runtime, but it's here for type checking. | ||
| # Type checkers fail to understand that the `set_{method}_request` | ||
| # methods are dynamically generated, and they complain that they are | ||
| # not defined. We define them here to make type checkers happy. | ||
| # During type checking analyzers assume this to be True. | ||
| # The following list of defined methods mirrors the list of methods | ||
| # in SIMPLE_METHODS. |
Contributor
Author
There was a problem hiding this comment.
I just copied the message from the source here to explain why these methods are there despite not existing at runtime.
…//github.com/Avasam/python-type-stubs into Replace-validate_stubs-scripts-with-stubtest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
validate_stubs.pydoesn't really work in its current state. I'm sure there's plenty more issues, but mainly it tries to import stub files and stubs-only symbols.Stubtest is as actively maintained as mypy and is a core tool to typeshed's own testing to validate that stubs match the content of implementation.
https://mypy.readthedocs.io/en/stable/stubtest.html
Updated.github/workflows/test.ymlto test both oldest and newest python version. This will help uncover issues likenumpy.distutilsnot being available on Python 3.12+utils/validate_stubs.pyin favor oftests/run_stubtest.pyWhilst all other tools help you ensure your stubs are valid, sane, or simply follow modern standards. This is actually the best metric you'll have to see how close the stubs are to actual implementation (or rather, how much they've diverged over time)