export names in __init__.pyi#171
Conversation
|
ooof.. looks like |
|
this actually goes much deeper. As I follow through the docs, I realize that a lot of the star imports
I don't want to sweep in and make any assumptions about the typing strategies here. @nclack, @aliddell, is this something you guys have thoughts on? I know it's annoying to keep static stubs up to date with native code, and it can make for a lot of duplicated stuff without having scripts to autogenerate and test them. is it something you already know about and have opinions on? |
|
First, we should add type-checking to our examples! Second, typing this stuff out made me think of a fix! Does #173 work for you @tlambert03? Anyway, for posterity, here's some answers to questions: I'm hoping that one day, we won't have to maintain the stubs by hand, but for now, it has to be manual. It's alright as long as we can catch it when it's wrong! The problem looks to be with re-exporting the types from import acquire
runtime = acquire.acquire.Runtime()
dm = runtime.device_manager()
for device in dm.devices():
print(device)
props = runtime.get_configuration()
props.video[0].camera.identifier=dm.select(acquire.acquire.DeviceKind.Camera)The stuff in |
yeppers |

without explicitly exporting names in
__init__.pyi, type checkers like mypy won't follow all the names and you won't get autocompletion and code highlighting. I know it's annoying to have to manually do this (and perhaps you will want to automate it if you're autogenerating your type stubs) ... but adding__all__is important one way or the otherbefore this PR:
after this PR: