Open kasium opened 1 year ago
Your code works well on the last version of invoke:
In [1]: from invoke.tasks import task
...: from invoke.collection import Collection
...:
...: @task
...: def foo(ctx):
...: pass
...:
...: ns = Collection()
...: ns.add_task(foo)
In [2]: ns
Out[2]: <Collection None: foo>
In [3]: ns.tasks
Out[3]: {'foo': <Task 'foo'>}
Which version of invoke
are you using? Maybe you may consider to upgrade it:
pip install invoke --upgrade
python -m invoke --version
# Your version need to be >= 2.1.3
Also, based on the documentation, you may simplify your imports:
from invoke import task
from invoke import Collection
@4sushi the code works but mypy complains as I said
leads to an mypy error: