dagster-io/dagster

Callable object custom signatures are resolved incorrectly

Open

#32,574 opened on Oct 21, 2025

 (2 comments) (1 reaction) (1 assignee)Python (1,174 forks)batch import
hacktoberfesttype: bug

Repository metrics

Stars
 (9,441 stars)
PR merge metrics
 (Avg merge 51d 21h) (8 merged PRs in 30d)

Description

What's the issue?

typing.get_type_hints supports callable objects with custom signature definitions (__call__ + __signature__).

Running get_type_hints on obj.__call__ instead of obj breaks that, and that's exactly what happened here.

The entire obj should be passed along and special cased for #18092 elsewhere. Sadly, the warning was not there when this was added.

What did you expect to happen?

obj.__signature__ to be used, rather than the raw signature of obj.__call__, which cannot be overwritten in any reasonable way.

How to reproduce?

def custom_signature(my_resource: MyResource) -> dg.MaterializeResult: ...

class MyWrapper():
  def __init__(self, fn: Callable[..., Any]) -> None:
    self.__signature__ = inspect.signature(custom_signature) # <- this is the signature I set
    
  def __call__(self, **kwargs: Any) -> Any: ... # <- this signature is used

my_resource will be interpreted as an "input", because it fails being recognized as a resource, due to missing type information.

Current behavior (get_type_hints(fn.__call__)):

{'kwargs': typing.Any, 'return': typing.Any}

Correct behavior (get_type_hints(fn)):

{'my_resource': <class 'my_project.MyResource'>, 'return': <class 'dagster._core.definitions.result.MaterializeResult'>}

Dagster version

1.11.15

Deployment type

Dagster Cloud

Deployment details

Irrelevant

Additional information

Broken in #18092

I'm aware Dagster has it's own get_type_hints wrapper, but passing the correct value there should fix this at least.

This is required for wrappers, which pass along dependencies from functions they're wrapping.

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.

Contributor guide