I'm finding that inheriting from a base class can change the derived class signature according to inspect.signature
, and I would like to understand how that happens. Specifically, the base class in question is tensorflow.keras.layers.Layer
:
import sys
import inspect
import tensorflow as tf
class Class1(tf.keras.layers.Layer):
def __init__(self, my_arg: int):
pass
class Class2:
def __init__(self, my_arg: int):
pass
print("Python version: ", sys.version)
print("Tensorflow version: ", tf.__version__)
print("Class1 signature: ", inspect.signature(Class1))
print("Class2 signature: ", inspect.signature(Class2))
Outputs
Python version: 3.8.10 (default, Mar 23 2023, 13:10:07)
[GCC 9.3.0]
Tensorflow version: 2.12.0
Class1 signature: (*args, **kwargs)
Class2 signature: (my_arg: int)
I tried running the code above and I expected it to print the same signature for both classes.