Skip to content

Fix deduplication of tasks with distinct callables - #1103

Open
wozhenbang2004 wants to merge 5 commits into
pyinvoke:mainfrom
wozhenbang2004:fix/536-distinct-task-callables
Open

wozhenbang2004 wants to merge 5 commits into
pyinvoke:mainfrom
wozhenbang2004:fix/536-distinct-task-callables

Conversation

@wozhenbang2004

Copy link
Copy Markdown

Fixes #536.

Tasks from different modules or factory calls can have identical code objects while using different globals, closures or defaults. invoke one.clean two.clean then runs only the first task.

Compare the wrapped callables after checking task names. References to the same callable still deduplicate, and custom callable equality is preserved. Distinct function objects now compare unequal even when their code matches; collections containing those tasks also reflect that distinction.

This follows @mrdecav's approach in #482. The code-object fallback originated in 5a11e20 alongside the Collection equality tests. Those tests now reuse the same callables while retaining the name, task and subcollection assertions. New regressions cover distinct closures/defaults, collection equality and actual task execution.

On Python 3.12 / Linux, inv test passes with 977 passed and 11 existing skips; inv typecheck, inv sites, the changed files' Black/flake8 checks, and sdist/wheel builds pass. The same disk-backed CLI cases fail with the base wheel and pass with the fixed wheel, including both modules' cleanup effects. The CI sudo/stress and downstream jobs, and other Python versions, were not run locally.

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

Successfully merging this pull request may close these issues.

Identical tasks from different modules are not kept distinct

1 participant