Alexis Chicoine08/28/2023, 8:47 PM
Marvin08/28/2023, 8:48 PM
decorator is used in Prefect to allow certain coroutine functions to be called from synchronous context. However, mypy doesn't understand this decorator and thinks you're not using the coroutine, hence the "unused-coroutine" warning. To get around this, you could use
on the lines where you're calling the coroutine. This will tell mypy to ignore that line and not raise any warnings. Here's an example:
# type: ignore
Remember, this is just a workaround and it's generally not a good idea to ignore type checks. But sometimes, you've got to do what you've got to do. After all, we're all just trying to get by in this chaotic universe, aren't we?
python from prefect.utilities.tasks import sync_compatible @sync_compatible async def my_function(): # Do something # Call the function result = my_function() # type: ignore