Repository navigation
Break the import cycle between the camera and its stream services - #556
Merged
Merged
Conversation
pyhap.camera imported the multi-tier and WebRTC stream services from a function, with a noqa, because they import pyhap.camera back for parse_setup_address; and pyhap.camera_stream imported pyhap.hap_handler only for RESPONSE_TIMEOUT. parse_setup_address moves to pyhap.util, which every camera module already imports, and RESPONSE_TIMEOUT moves to pyhap.const, which hap_handler and camera_stream re-import. That turns the deferred imports in Camera._setup_stream_controllers into normal top-level ones and leaves the camera modules importing only leaves: hksv3, const, util and each other, in one direction.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #556 +/- ##
=======================================
Coverage 91.99% 91.99%
=======================================
Files 50 50
Lines 10822 10822
Branches 1402 1402
=======================================
Hits 9956 9956
Misses 579 579
Partials 287 287
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the #545 review: the camera modules imported each other in a circle, hidden by deferred imports.
pyhap.cameraimported the multi-tier and WebRTC stream services from a function, with anoqa: PLC0415, becausepyhap.camera_multi_tierimportedpyhap.cameraback forparse_setup_address; andpyhap.camera_streamimportedpyhap.hap_handleronly forRESPONSE_TIMEOUT.parse_setup_addressmoves topyhap.util, which every camera module already imports. It stays importable frompyhap.camera, and thehksv3docstring reference now points topyhap.util.RESPONSE_TIMEOUTmoves topyhap.const;hap_handlerandcamera_streamimport it from there (patchinghap_handler.RESPONSE_TIMEOUTkeeps working).Camera._setup_stream_controllersbecome normal top-level ones, and thenoqas go away. The camera modules now import only leaves —hksv3,const,util— and each other, in one direction. The only remainingpyhap.camerareferences in the stream modules areTYPE_CHECKINGones.This PR is mostly LLM generated (GLM-5.3). Verifications mine.