Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
James-Ansley opened this issue Oct 1, 2024 · 0 comments
Open

Comments

@James-Ansley
Copy link

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.

@James-Ansley James-Ansley changed the title Generic type hints for verify_all's alist and formatter paramters Generic type hints for verify_all's alist and formatter parameters Oct 2, 2024
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

No branches or pull requests

1 participant