Skip to content

Declare element types for post_processor_thread_dict and forwarding_plugins - #885

Merged
tmaeno merged 2 commits into
PanDAWMS:masterfrom
tmaeno:master
Nov 24, 2026
Merged

tmaeno merged 2 commits into
PanDAWMS:masterfrom
tmaeno:master

Conversation

@tmaeno

@tmaeno tmaeno commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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:

  • Added an explicit type annotation to self.post_processor_thread_dict in jedi_post_processor_msg_processor.py to specify it as a dictionary with tuple keys and PostProcessorThread values.
  • Annotated self.forwarding_plugins in status_report_msg_processor.py as a list of KafkaMsgProcPlugin objects for better clarity and static analysis.

Type Checking Imports:

  • Imported TYPE_CHECKING and conditionally imported KafkaMsgProcPlugin in status_report_msg_processor.py to avoid runtime import cycles while supporting type hints.

tmaeno and others added 2 commits November 24, 2026 15:25
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.
@tmaeno
tmaeno merged commit 03f4880 into PanDAWMS:master Nov 24, 2026
1 check passed
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.

1 participant