Last active
September 4, 2023 10:16
-
-
Save nekufa/ba1806696db733bd5a9b6ecdc99f670b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from types import GenericAlias | |
from typing import get_type_hints | |
async def tester(param: list[str]): | |
return [ | |
x + '!' for x in param | |
] | |
async def another_tester(param: str): | |
return param + '!' | |
todo = ['a', 'b', 'c', 'd'] | |
for task in [tester, another_tester]: | |
params_class = list(get_type_hints(task).values())[0] | |
batch_handler = type(params_class) is GenericAlias | |
if batch_handler: | |
task(todo) | |
else: | |
for x in todo: | |
task(x) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.