-
Notifications
You must be signed in to change notification settings - Fork 205
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
refactor: add type annotations and improve type safety #1205
Conversation
Signed-off-by: KarimAziev <[email protected]>
This will preserve original behavior Signed-off-by: KarimAziev <[email protected]>
Signed-off-by: KarimAziev <[email protected]>
Signed-off-by: KarimAziev <[email protected]>
Signed-off-by: KarimAziev <[email protected]>
Signed-off-by: KarimAziev <[email protected]>
Signed-off-by: KarimAziev <[email protected]>
Thanks for this PR. Looks like I need to install a newer version of typing-extensions than the Bookworm default. I'll do that and then re-open this so that it runs again. |
That looks good, there's just one snag I've run into related to the line
Because we ship Picamera2 installed in our regular OS images, it means that I can't use a version of typing_extensions that isn't in our Bookworm apt repo. The version currently there is 4.4.0. But for this line to work I think I need at least 4.8.0. So the solutions are probably:
I'll see whether it looks possible to update the Bookworm repo (does 4.8.0 sound OK to you?) and then post back. Thanks again! |
Signed-off-by: KarimAziev <[email protected]>
Thanks for the feedback! I've removed it for now, so an updated version of |
This PR introduces significant improvements to type hinting as part of resolving issue #1192.
dispatch_functions
, ensuring that it now correctly propagates return types.Job
class into a generic type.capture_array
,capture_image
, andcreate_video_configuration
.assert
statements.pyright
configuration: disabled thereportUnknownMemberType
warning, resulting in fewer but more meaningful warnings being displayed.While the PR mainly focuses on typing improvements with no logical changes, there's a minor fix in
Job.cancel()
:Before:
Now:
This change ensures that
set_exception
is always given an instance ofCancelledError
, aligning withconcurrent.futures.Future
's expectations. The previous version would have raised aTypeError: exceptions must be derived from BaseException when raised
if it were ever encountered at runtime. This fix does not alter any behavior but ensures correctness.P.S. I didn't plan for this to be so extensive, but... it turned into a rabbit hole.