Skip to content

Generic type hints for verify_all's alist and formatter parameters #176

@James-Ansley

Description

@James-Ansley

The verify_all function currently hints the parameters a_list as List[str] and formatter as Optional[Callable]. Perhaps better type hints would be (using 3.12 syntax but this could be done with the old-style generic type syntax):

def verify_all[T](
    ...
    alist: List[T],
    formatter: Optional[Callable[[T], str]] = None,
    ...
) -> None:

This would allow for any object to be passed in as the expected result with the formatter transforming the object into a string for approval — without type checkers complaining.

In fact, the default formatter for this function already calls str by default on objects from alist (see list_utils.py) when transforming the list to a string.

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