Skip to content

Warn when activity method is registered without an instance - #1918

Open
vjymisal0 wants to merge 1 commit into
temporalio:mainfrom
vjymisal0:warn-unbound-activity-method
Open

vjymisal0 wants to merge 1 commit into
temporalio:mainfrom
vjymisal0:warn-unbound-activity-method

Conversation

@vjymisal0

Copy link
Copy Markdown

What was changed

When building the activity worker, if a registered activity is a plain function whose first parameter is self, the worker now emits a UserWarning. That almost always means someone passed MyActivities.my_method instead of MyActivities(...).my_method, and today that only shows up later as a confusing failure when the activity runs.

It's a warning rather than an error so nothing that currently works (e.g. odd but intentional function signatures) breaks.

Also added a test next to the existing callable-class bad-register test, and a changelog entry under Added.

Why

Closes #377

Checklist

  • Added test_workflow_activity_method_unbound_register in tests/worker/test_workflow.py; it fails without the change and passes with it.
  • Ran the related tests locally (-k "activity_method or callable_class") and all of tests/worker/test_activity.py, all passing, and confirmed no existing test triggers the new warning.
  • ruff check --select I, ruff format --check, pyright and mypy are clean on the changed files.

@vjymisal0
vjymisal0 requested a review from a team as a code owner October 2, 2026 13:43
@CLAassistant

CLAassistant commented Oct 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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.

[Feature Request] Warn when non-static activity method registered as static

2 participants