Skip to content

Add typing to worker module - #38

Open
JuanTecedor wants to merge 2 commits into
TheHive-Project:masterfrom
JuanTecedor:add_typing_to_worker_module
Open

Add typing to worker module#38
JuanTecedor wants to merge 2 commits into
TheHive-Project:masterfrom
JuanTecedor:add_typing_to_worker_module

Conversation

@JuanTecedor

@JuanTecedor JuanTecedor commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

This PR addresses #37.

I've tried to keep types wide for now.

TODO:

  • Check if all typing used is Python 3.10 compatible.
  • Review design decisions in comments

Comment thread cortexutils/worker.py
name: str | list[str],
default: Any = None,
message: str | None = None,
) -> Any:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without validation I'm not convinced it is worth it to narrow the return type beyond Any, but we could narrow it down to a JSON subset dict | list | str | int | float | bool | None (https://docs.python.org/3/library/json.html#json.JSONEncoder).

Other option is to break compatibility and add a function with a expected_type param that errors if an isinstance check fails, for example.

Comment thread cortexutils/worker.py
Comment thread cortexutils/worker.py


class Worker:
READ_TIMEOUT = 3 # seconds

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unused. Again, chance to break compatibility

Comment thread cortexutils/worker.py
Comment thread cortexutils/worker.py
@Kamforka Kamforka added the changelog:added changelog label for new features. label Jun 20, 2026
@Kamforka
Kamforka self-requested a review June 20, 2026 11:02
@Kamforka Kamforka added this to the 2.3.0 milestone Jun 20, 2026
@Kamforka Kamforka linked an issue Jun 20, 2026 that may be closed by this pull request
@JuanTecedor
JuanTecedor marked this pull request as ready for review June 22, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:added changelog label for new features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add typing to Worker module

2 participants