-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Closed
Description
Hi! This is a followup to #3478 - thanks for accepting that PR.
Now that I've updated my project to use the latest version of Tornado, gen.multi() is much nicer about the inputs I want to pass to it, but its outputs are kind of a pain to use. Currently it returns list | dict, which means that if I do result = gen.multi(a_dict), type checkers make me do assert isinstance(result, dict) before I can do anything useful with result.
I have a minimal repro here: https://github.com/jrheard/tornado-gen-repro/blob/main/main.py , which gives this mypy output (and similar output in pyright):
π uv run mypy main.py
main.py:24: error: Argument 1 to "takes_list" has incompatible type "list[Any] | dict[Any, Any]"; expected "list[int]" [arg-type]
main.py:25: error: Argument 1 to "takes_dict" has incompatible type "list[Any] | dict[Any, Any]"; expected "dict[str, int]" [arg-type]
Found 2 errors in 1 file (checked 1 source file)
I think that it should be possible to use typing.overload to make multi()'s return value a bit easier to use. I hope to submit a PR shortly!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels