Fix TypeError in tasks.py