Closed blueyed closed 4 years ago
btw: https://github.com/davidfritzsche/pytest-mypy-testing/ might be interesting for testing the stubs.
Awesome! Will really help with pytest typing.
I have some general comments below, will follow up with concrete comments.
First, I assume that given py
is in maintenance mode, the idea is only to add typing for external use and not for internal/development use. And also that we'll probably never want to integrate the types into the code itself, only pyi
files.
Given that, I think that the stubs should only really expose the public API, and not include internal/private details. And also, only importable items (functions, classes, etc.) should be included. Or if we want to expose private items, we should prefix them with _
so it's clear they are only "helpers" for the stubs (this is what typeshed does).
py does some weird things with imports but the __init__.py
at least makes it very easy to see what is the public API of the package.
@bluetech
Agree!
Most of the internal things is generated via stubgen
, I am adjusting it as I find issues - have not really checked if I am missing some local changes.
It's rather messy still, but when installed helps mypy already.
BTW, I just checked the pytest
code and from the best I can find, these are the imports from py
that pytest uses:
py.error.Error
py.iniconfig.IniConfig
py.iniconfig.ParseError
py.io.dupfile
py.io.get_terminal_width
py.io.TerminalWriter
py.path.local
py.xml.escape
py.xml.Namespace
py.xml.raw
Might help direct the focus.
Most of the internal things is generated via stubgen, I am adjusting it as I find issues - have not really checked if I am missing some local changes.
stubgen is great for this, but I think we should take its output, trim it down and restructure it, as I suggested above, and later also fill up the Any
s. WDYT?
(I can help with the effort if you'd like)
stubgen is great for this, but I think we should take its output, trim it down and restructure it, as I suggested above, and later also fill up the Anys. WDYT?
Sure, of course.
Your help would be appreciated of course. Feel free to go crazy on the branch - hopefully you can push here?
Your help would be appreciated of course. Feel free to go crazy on the branch - hopefully you can push here?
Great, I can do it now. I'll just send a PR with my suggestions against your repo so you can decide what to do.
Closing in favor of https://github.com/pytest-dev/py/pull/232.
This is meant to be used for pytest, which mainly uses
py.path.local
, and is very much work in progress./cc @bluetech