Skip to content

Incomplete type given in EDA plugin template #708

Open
@ssbarnea

Description

@ssbarnea

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

The example given in https://ansible.readthedocs.io/projects/rulebook/en/latest/sources.html#plugin-template does have incomplete type signature (running mypy --strict would highlight the issues).

async def main(queue: asyncio.Queue, args: Dict[str, Any]):
  • First argument should be more like asyncio.Queue[Dict[str, Any])]
  • The args being just a generic Dict[str, Any] might not be the best type due to the use of Any - gives too much freedom and does not help plugin authors to easily write them. It would be desirable to be a more constrained type, if possible. Even defying a specific class for this purpose might help as plugins could import it for typing purposes.

Environment

Steps to reproduce

Actual results

Expected results

Complete type signature, maybe even including some examples of what kind of data would be received by the plugins.

Additional information

It should be noted that I found this while adding types to EDA collection as part of ansible/event-driven-ansible#258

If the data passed is generic JSON, it could prove useful to know that now we do have some JSON types compatible with mypy, we already defined them in https://github.com/ansible/ansible-compat/blob/main/src/ansible_compat/types.py#L13 as we needed them for several projects managed by devtools, feel free to copy them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions