Collection mix-up when cross importing invoke tasks
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the behavior using tasks/init.py, module_a.py, and module_b.py from the report, then run inv -l and inv module-a.my-task-b1. Trace how the imported task is registered in the two collections. Done means the imported task is not listed or invokable under module-a while remaining available under module-b, with regression coverage for this example.
Written by the indexing model from the issue text.
Description
Problem statement
Hey ! Just stumbled upon something working with Invoke and I don't know if that's a feature or a bug so I'm filing a small issue !
TL; DR: When having 2 collections module_a and module_b. If I import my_task_b1 from module_b to module_a, then the module_a.my_task_b1 will be a valid invoke task (i.e I can use it and inv -l lists it as well). I don't think it should be the case.
Steps to reproduce
Install invoke (pip install invoke)(I'm using 2.2.0). Here is the folder architecture:
.
└── tasks
├── __init__.py
├── module_a.py
└── module_b.py
__init__.py
from invoke import Collection
from . import (
module_a,
module_b
)
ns = Collection()
ns.add_collection(module_a)
ns.add_collection(module_b)
module_a.py
from invoke import task
from .module_b import my_task_b1
@task
def my_task_a(_):
my_task_b1(_)
print("Hey there !")
module_b.py
from invoke import task
@task
def my_task_b1(_):
print("Hola !")
@task
def my_task_b2(_):
print("Hola !")
When I run inv -l I get the following invoke tasks:
Available tasks:
module-a.my-task-a
module-a.my-task-b1
module-b.my-task-b1
module-b.my-task-b2
Also running it worka:
> inv module-a.my-task-b1
Hola !
Is this on purpose ? I would expect not to have module-a.my-task-b1 !
Behaviour I would have expected
I would have expected inv -l to output
Available tasks:
module-a.my-task-a
module-b.my-task-b1
module-b.my-task-b2
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 412
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pyinvoke/invoke
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·