Skip to content

2.0.1

Latest

Choose a tag to compare

@github-actions github-actions released this 11 Jul 10:05
92d96bb

modern-di-celery 2.0.1 — @inject variadic fail-fast

A patch release fixing silent argument corruption in @inject.

Fix

  • @inject now rejects *args/**kwargs at decoration time. Since 2.0.0,
    @inject binds a task's arguments to its visible signature by name (which is
    what makes injection parameter-order-insensitive). That by-name call could not
    faithfully forward variadic parameters: inspect.Signature.bind stores
    *args/**kwargs values under the literal names "args"/"kwargs", so a
    task declaring *args/**kwargs alongside a FromDI parameter had its
    real payload silently misrouted into a keyword argument (e.g. a caller's
    (1, 2, foo="bar") arrived inside the task as args=(), kwargs={"args": (1, 2), "kwargs": {"foo": "bar"}}) instead of raising.

    @inject now raises a clear TypeError at decoration time when a task
    declares a VAR_POSITIONAL or VAR_KEYWORD parameter together with a FromDI
    parameter, naming the offending parameter and pointing at explicit named
    parameters as the fix. A task with no FromDI parameter is returned
    unchanged and may use *args/**kwargs freely.

Downstream

  • Potentially breaking, intentionally. A task that previously combined
    @inject/DITask with *args/**kwargs and a FromDI parameter was already
    broken at runtime (silently corrupted arguments); it now fails loudly at import
    time. Replace the variadic parameters with explicit named parameters.

Internals

  • 100% line coverage; ruff, ty, and eof-fixer clean. Two new tests cover
    the VAR_POSITIONAL and VAR_KEYWORD rejection paths.