google/fiddle

Incorrect signature parsing for subclass of Generic

ppwwyyxx opened this issue · 0 comments

from typing import Generic, TypeVar
T = TypeVar('T')

def print_sig(callable, *args, **kwargs):
    from fiddle._src import signatures
    kwargs = signatures.SignatureInfo.signature_binding(callable, *args, **kwargs)
    print(kwargs)

class A:
    def __init__(self, a, b=1):
        pass

class B(Generic[T]):
    def __init__(self, a, b=1):
        pass

print_sig(A, 3, 1)
print_sig(B, 3, 1)

Using github HEAD today, the above code prints:

{'a': 3, 'b': 1}
{'self': 3, 'a': 1}