-
-
Notifications
You must be signed in to change notification settings - Fork 343
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 pyright --verifytypes
to CI & checks
#2625
Comments
For reference: #2623 shows 39 symbols being typed (though some are incomplete) while it lists 314 symbols as not typed, so about 11% complete. Though this can probably be improved quite quickly by copying over from the stubs, and leave typing messy internal functions for later. |
On one hand, the pyright design decision is really stupid. On the other hand, I hate "private" packages/modules. I'd say I support removing private packages (and just making a normal package layout) more. |
We're not going to remove the underscores from the internal implementation modules... I've been burned too often by Hyrum's law :-) The details of how pyright does this are annoying, but it's actually good that it won't let code that uses our private names directly type-check. The idea is to make sure that what we make public as supported interfaces is exactly what we intend it to be, no more or less. IIRC if we do Using |
I believe everything in this issue is done? (I've ticked the checkboxes just to make sure) If not, feel free to reopen! |
In order to be able to eventually retire trio-typing (see https://github.com/python-trio/trio-typing), track progress on #543 (and once type complete, make sure that we stay that way) and as a minor bonus give a check on docstrings, I suggest adding
pyright --verifytypes
to the checks in CI, that at a beginning is required only to go up from current state, and when we've achieved 100% type completeness will then require not dropping below that.See #2623 where I reinvented the wheel in a quite clunky way and some discussion around it, https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#type-completeness for the definition of type completeness, and https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#verifying-type-completeness for documentation on
--verifytypes
.There's unfortunately a couple blockers before we're able to use it.
__init_.py
,socket.py
,abc.py
,from_thread.py
,lowlevel.py
,socket.py
andto_thread.py
are not visible to--verifytypes
. Also related to Use less magic in constructing our public API exports, to make trio more intelligible to static analysis #542__all__
, see discussion in Simplify imports #594 (comment)from X import A as A
- a bit verbose, but simplefrom X import *
- I'm not sure if we're currently exporting everything, so this might expose more symbols unless they are/get named with a leading underscore.__init__
's for the different submodules, and remove leading underscores from file names. (this has likely been discussed in Use less magic in constructing our public API exports, to make trio more intelligible to static analysis #542 and other places and there's presumably some decent logic for the current layout?).trio/tests
totrio/_tests
, moving it out to a separate top-leveltests/
, or removingtrio/tests/__init__.py
.--outputjson
and dump the results in a_type_completeness.json
, which incheck.sh
is parsed for the % and the individual values, then regenerated on the new code and reparsed, and finally compare the individual values so none of them are dropping (other than the number of symbols exported, or the number of symbols exported with known type.) This'd be a quick&dirty python/shell script, and can make it take a command-line flag whether to overwrite the file or not (that is set in CI, but otherwise not) so it can be used locally repeatedly when developing.Ticking all these boxes is definitely gonna take a while and bunch of discussion, so I don't personally consider it completely out of the question to use #2623 in the meanwhile - but a better solution would probably be a dirty script that does something like
__init__.py
and friends to change all the imports tofrom X import A as A
trio/tests/
directoryThis can then be retired/simplified as 1&2 are fixed.
@A5rocks @Fuyukai @Zac-HD @njsmith
The text was updated successfully, but these errors were encountered: