Skip to content
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

Resolve various type errors and do some pythonic refactoring of the codebase #1179

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

pantheraleo-7
Copy link

@pantheraleo-7 pantheraleo-7 commented Dec 17, 2024

Partly inspired by the edit of #1177 (Comment)

Type errors resolved in:

  1. close
  • Sets the camera_ctrl_info to an empty dict, hence keeping the same type. This approach could also be seen in _reset_flags L297
  • Sets the *_configuration properties to empty CameraConfiguration objects, hence keeping the same type.
  1. __init__
  • Initialise the *_configuration_ attributes instead of setting the *_configuration properties which uses the *_configuration_ attributes under the hood without properly initialising them.

Refactors done in:

  1. _initialize_camera
  • It only ever returned True or raised RuntimeError, so using a bool return type doesn't make sense and is non-pythonic. The downstream usage by _open_camera expects a return value of False in case of failure, but False is never returned.
  1. _open_camera
  • Now it actually catches the error.
  • Earlier when _initialize_camera returned True, the if block was skipped. In the failure case of _initialize_camera, the error was propagated, the if block never got the chance to execute.

@pantheraleo-7 pantheraleo-7 changed the title Correct logical errors in __init__ (and solve various related problems) Resolve various type errors and do some pythonic refactoring of the codebase Dec 17, 2024
@pantheraleo-7 pantheraleo-7 marked this pull request as ready for review December 17, 2024 18:58
@davidplowman davidplowman merged commit acba763 into raspberrypi:next Dec 18, 2024
4 checks passed
@pantheraleo-7 pantheraleo-7 deleted the conf branch December 18, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants