Feature: add signature exposure for static inference - #808
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
49406c6 to
38bf8f3
Compare
38bf8f3 to
039abcd
Compare
|
Does this work @munechika-koyo ? |
|
TODO: get an editor with pylance |
|
From my understanding yes. Custom stubs would work but that is very not handy to maintain. |
|
So had a bit more digging. The solution it seems is that one would have to generate and comit the stubs to the repo in order for it to work with the static viewer properly. This is also how mpl does it. |
|
It's true that management costs might go up, but that seems like the better option for generating stubs in a runtime environment, for example, using mypy's |
|
Can you check the editor with the stubs added? (30k jeezzzz) |
|
In my environment with Anyway, there appear to be many UltraPlot/ultraplot/constructor.pyi Line 118 in f2571e1 Were they caused by automatic generation? Is it possible to fix the types for them? |
|
Most of the codebase is not type annotated yet and the automatic inference fallsback to Incomplete I think |
|
Wouldn't this solve all the issues: https://marketplace.visualstudio.com/items?itemName=KiidxAtlas.python-hover |
|
hmm annoying. |
|
I added a dynamic inspector prior to dumping the stubs to expand the stubs, does this work @munechika-koyo ? |
|
Note there is another small issue that proplot clearly intended the docs to be used as a replacement. So many of the docstrings are near novels. |
|
Nvm I noticed I broker a bunch of stuff for myself now. I will fix that first before I ping again. |
|
@munechika-koyo can you check this PR again. At least on basedpyright is working now. |
|
|
|
Need to explore if there is not another way. Potentially we would need to get rid of how the docstrings are expanded. |
|
OK, to avoid adding way too many files, it may be better to offer the "stub" package instead, like |
|
I preferably don't want to manually keep track of the stubs. I can automate it for deving through workflows but it will still be annoying as autocommits would need to be pulled back down to sync up (or regenerated). The major issue is that ProPlot was using DRY principles to weave in docstrings that are fine for run time inspection but not for these static inspectors. Redoing all the doc strings violates that principle, but that would gain having the doc strings where they actually belong (in the function description). What I don't like right now is that the doc strings are defined early on in the document and not where the function actually sits, but I recognize the complexity of the dynamic and DRY stuff |
|
I presume the dynamic strategy in this library is key from the perspective of API simplicity at runtime. (e.g. If it is hard to build the stub files into the CI automation, what about moving it into the pre-CD workflow? Anyway, we probably need to find the best way to automate stub creation in CI. |
|
pre-commit.ci autofix |
|
I have added the stubs for wheel releases -- this way users have it while not needing to add the stubs in the dev version. |




UltraPlot does a lot of runtime composition (lazy loading, dynamic dispatch, shared doc merging, and compact documentation signatures), which makes static analysis difficult because analyzers see only source-level declarations rather than the final runtime-expanded API.
This PR now takes a single-source approach:
.pyfiles remain the only authored API representation..pyifiles.Editable/source installs keep the existing runtime docstring expansion behavior; normal wheel installs get statically visible expanded docstrings.