Repository navigation
Declare element types for post_processor_thread_dict and forwarding_plugins - #885
Merged
Merged
Conversation
The post-processor and status-report message processor plugins make a container field empty in initialize, fill it there with objects of one class, and call methods on its elements in process. mypy infers the element types from the stores in initialize, but a reader of process alone does not see them. Declare both where they are made: - post_processor_thread_dict maps (vo, prodsourcelabel) to the PostProcessorThread serving them, as the comment above it says. Both come from procConfig, where an empty field becomes None, so the key is declared optional, as in the job generator's message processor. - forwarding_plugins holds the KafkaMsgProcPlugin instances that messages are forwarded to. The module imports that plugin only when it is configured, so the declaration imports it under TYPE_CHECKING. No change at runtime.
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.
This pull request improves type safety and code clarity in the message processor modules by adding explicit type annotations and type-checking imports. The most significant changes are:
Type Annotations Enhancements:
self.post_processor_thread_dictinjedi_post_processor_msg_processor.pyto specify it as a dictionary with tuple keys andPostProcessorThreadvalues.self.forwarding_pluginsinstatus_report_msg_processor.pyas a list ofKafkaMsgProcPluginobjects for better clarity and static analysis.Type Checking Imports:
TYPE_CHECKINGand conditionally importedKafkaMsgProcPlugininstatus_report_msg_processor.pyto avoid runtime import cycles while supporting type hints.