Repository navigation
Conversation
head_from_fun() builds the function that apply_async() calls to check
the arguments of a task. It was generated from the full argspec, which
lists positional-only arguments together with the regular ones, so the
"/" marker was lost.
A task defined as f(x, /, **kwargs) could not be called with a keyword
named x ("got multiple values for argument"), and a call that passed a
positional-only argument by keyword was accepted and only failed in the
worker.
MehrazRumman
left a comment
Contributor
There was a problem hiding this comment.
Checked at 1e6ff97.
- The bug is real, and the fix is in the right place.
getfullargspecdoesn't mark positional-only parameters, so the generated header lost the/. Readingco_posonlyargcountfrom the same callable and inserting/after that many positional entries gives the right header. It also works with defaults,*args, keyword-only parameters and**kwargs. For example,def f(a, b=1, /, c=2, *rest, d, **kw)now generatesdef f(a, b=0, /, c=1, *rest, d, **kw). t/unit/utils/test_functional.pyandt/unit/tasks/test_tasks.pypass (219 passed, 1 xfailed). All five newhead_from_funcases andtest_typing__positional_onlyfail againstmain.- Callables without a
__code__fall back to0and are unchanged. For class-based callables,fun.__call__is a bound method whose__code__count includesself, the same as the argspec, so the two stay consistent.
The CI workflows for this commit are still waiting for maintainer approval. Looks good to me.
auvipy
self-requested a review
October 17, 2026 10:57
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10870 +/- ##
==========================================
- Coverage 90.56% 90.55% -0.01%
==========================================
Files 153 153
Lines 21367 21370 +3
Branches 2608 2609 +1
==========================================
+ Hits 19350 19352 +2
Misses 1704 1704
- Partials 313 314 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Before submitting this pull request, please review our contributing
guidelines.
Description
apply_async()checks the arguments of a call against the task signature with a function generated byhead_from_fun(). The generated function is written from the full argspec, which lists positional-only parameters together with the regular ones, so the/marker is lost and the check no longer matches the task:_argsfromspec()now takes the number of positional-only parameters (read from the code object of the same callable) and writes the/in the generated header. Callables without a code object are unchanged.Tests: five cases in
test_head_from_fun(plain, name reused as a keyword, all parameters positional-only, combined with keyword-only, bound) andtest_typing__positional_onlyintest_tasks.py. All six fail onmain. Checked on Python 3.12 and 3.14.