Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection mix-up when cross importing invoke tasks #979

Open
amenasria opened this issue Dec 8, 2023 · 0 comments
Open

Collection mix-up when cross importing invoke tasks #979

amenasria opened this issue Dec 8, 2023 · 0 comments

Comments

@amenasria
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant