@@ -15,8 +15,52 @@ tensorflow.DType.__getattr__
1515tensorflow.Graph.__getattr__
1616tensorflow.Operation.__getattr__
1717tensorflow.Variable.__getattr__
18+ tensorflow.keras.layers.Layer.__getattr__
1819# Internal undocumented API
1920tensorflow.RaggedTensor.__init__
2021# Has an undocumented extra argument that tf.Variable which acts like subclass
2122# (by dynamically patching tf.Tensor methods) does not preserve.
2223tensorflow.Tensor.__getitem__
24+ # stub internal utility
25+ tensorflow._aliases
26+
27+ # Tensorflow imports are cursed.
28+ # import tensorflow.initializers
29+ # import tensorflow as tf
30+ # tf.initializers
31+ # Usually these two ways are same module, but for tensorflow the first way
32+ # often does not work and the second way does. The documentation describes
33+ # tf.initializers as module and has that type if accessed the second way,
34+ # but the real module file is completely different name (even package) and dynamically handled.
35+ # tf.initializers at runtime is <module 'keras.api._v2.keras.initializers' from '...'>
36+ tensorflow.initializers
37+
38+ # Layer constructor's always have **kwargs, but only allow a few specific values. PEP 692
39+ # would allow us to specify this with **kwargs and remove the need for these exceptions.
40+ tensorflow.keras.layers.*.__init__
41+
42+ # __call__ in tensorflow classes often allow keyword usage, but
43+ # when you subclass those classes it is not expected to handle keyword case. As an example,
44+ # class MyLayer(tf.keras.layers.Layer):
45+ # def call(self, x):
46+ # ...
47+ # is common even though Layer.call is defined like def call(self, inputs). Treating inputs as
48+ # a keyword argument would lead to many false positives with typical subclass usage.
49+ # Additional awkwardness for Layer's is call may optionally have training/mask as keyword arguments and some
50+ # layers do while others do not. At runtime call is not intended to be used directly by users,
51+ # but instead through __call__ which extracts out the training/mask arguments. Trying to describe
52+ # this better in stubs would similarly add many false positive Liskov violations.
53+ tensorflow.keras.layers.*.call
54+ tensorflow.keras.regularizers.Regularizer.__call__
55+ tensorflow.keras.constraints.Constraint.__call__
56+
57+ # Layer class does good deal of __new__ magic and actually returns one of two different internal
58+ # types depending on tensorflow execution mode. This feels like implementation internal.
59+ tensorflow.keras.layers.Layer.__new__
60+
61+ # build/compute_output_shape are marked positional only in stubs
62+ # as argument name is inconsistent across layer's and looks like
63+ # an implementation detail as documentation never mentions the
64+ # disagreements.
65+ tensorflow.keras.layers.*.build
66+ tensorflow.keras.layers.*.compute_output_shape
0 commit comments