Skip to content

Conversation

@oliverhaas
Copy link
Contributor

@oliverhaas oliverhaas commented Jan 8, 2026

Basically same as #207.

CI should pass if #207 and #209 are merged before this...

Significantly expanded type stubs for the celery package:

- Added many new modules: app/annotations, app/autoretry, app/backends,
  app/builtins, app/defaults, app/trace, apps/beat, apps/multi
- Added backend stubs: arangodb, asynchronous, azureblockblob, cache,
  cassandra, consul, cosmosdbsql, couchbase, couchdb, dynamodb,
  elasticsearch, filesystem, gcs, mongodb, redis, rpc, s3
- Added bin stubs: amqp, base, beat, call, celery, control, events,
  graph, list, logtool, migrate, multi, purge, result, shell, upgrade, worker
- Added concurrency stubs: asynpool, base, eventlet, gevent, prefork, solo, thread
- Added worker stubs: components, consumer/*, control, heartbeat, loops,
  pidbox, request, state, strategy, worker
- Added utils stubs: collections, debug, dispatch, functional, graph, imports,
  iso8601, log, nodenames, objects, serialization, term, text, threads, time, timer2
- Enhanced existing module type annotations with more complete signatures
- Added @OverRide decorators for proper method override annotations
@oliverhaas oliverhaas force-pushed the celery-stubs-improvements branch from b0571fe to e3460ff Compare January 8, 2026 19:09
autofinalize: bool = True,
namespace: str | None = None,
strict_typing: bool = True,
broker_connection_retry: bool = ...,
Copy link
Contributor

@9en9i 9en9i Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these arguments really missing? Or is this a mistake? I assume that these arguments are actually present in kwargs, and if so, I think it would be more useful to explicitly mark them as keyword-only using *,.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Celery makes this kind of awkward, since it's not an explicit kwarg in the actual code. I guess keeping it makes more sense from a practical point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the other places. I have seen it in at least one other class. And, by the way, perhaps it would make sense to mark them with '*,'?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

….apply_async

Restore explicit keyword arguments for better IDE autocomplete support:

- Celery.__init__: Add config kwargs (imports, broker_*, result_*, task_*, worker_*)
- Celery._task_from_fun: Add autoretry and task option kwargs
- Signature.apply_async: Add options kwargs (task_id, producer, link, countdown, etc.)

Use keyword-only syntax (*,) to satisfy stubtest while still providing
typed kwargs for IDE support.
@oliverhaas oliverhaas force-pushed the celery-stubs-improvements branch from ed8bf79 to 60d818d Compare January 8, 2026 20:53
@oliverhaas oliverhaas marked this pull request as draft January 8, 2026 21:19
)

current_app: Proxy[Celery]
current_task: Proxy[Task[Any, Any]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the 'Proxy' class is needed here. I think it would be better for typing if it were a type without a proxy.

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.

2 participants