Use PEP 570 syntax in third party stubs (#11554)

This commit is contained in:
Shantanu
2024-03-10 06:11:43 -07:00
committed by GitHub
parent f94bbfbcc4
commit 88fa182253
97 changed files with 625 additions and 632 deletions

View File

@@ -146,13 +146,14 @@ class Dataset(ABC, Generic[_T1]):
) -> Dataset[tf.Tensor]: ...
@staticmethod
@overload
def range(__stop: ScalarTensorCompatible, output_type: DType = ..., name: str | None = None) -> Dataset[tf.Tensor]: ...
def range(stop: ScalarTensorCompatible, /, output_type: DType = ..., name: str | None = None) -> Dataset[tf.Tensor]: ...
@staticmethod
@overload
def range(
__start: ScalarTensorCompatible,
__stop: ScalarTensorCompatible,
__step: ScalarTensorCompatible = 1,
start: ScalarTensorCompatible,
stop: ScalarTensorCompatible,
step: ScalarTensorCompatible = 1,
/,
output_type: DType = ...,
name: str | None = None,
) -> Dataset[tf.Tensor]: ...

View File

@@ -6,7 +6,7 @@ from tensorflow import Tensor
class Constraint:
def get_config(self) -> dict[str, Any]: ...
def __call__(self, __w: Tensor) -> Tensor: ...
def __call__(self, w: Tensor, /) -> Tensor: ...
@overload
def get(identifier: None) -> None: ...

View File

@@ -56,15 +56,15 @@ class Layer(tf.Module, Generic[_InputT, _OutputT]):
# First argument will automatically be cast to layer's compute dtype, but any other tensor arguments will not be.
# Also various tensorflow tools/apis can misbehave if they encounter a layer with *args/**kwargs.
def __call__(self, inputs: _InputT, *, training: bool = False, mask: TensorCompatible | None = None) -> _OutputT: ...
def call(self, __inputs: _InputT) -> _OutputT: ...
def call(self, inputs: _InputT, /) -> _OutputT: ...
# input_shape's real type depends on _InputT, but we can't express that without HKT.
# For example _InputT tf.Tensor -> tf.TensorShape, _InputT dict[str, tf.Tensor] -> dict[str, tf.TensorShape].
def build(self, __input_shape: Any) -> None: ...
def build(self, input_shape: Any, /) -> None: ...
@overload
def compute_output_shape(self: Layer[tf.Tensor, tf.Tensor], __input_shape: tf.TensorShape) -> tf.TensorShape: ...
def compute_output_shape(self: Layer[tf.Tensor, tf.Tensor], input_shape: tf.TensorShape, /) -> tf.TensorShape: ...
@overload
def compute_output_shape(self, __input_shape: Any) -> Any: ...
def compute_output_shape(self, input_shape: Any, /) -> Any: ...
def add_weight(
self,
name: str | None = None,

View File

@@ -8,7 +8,7 @@ class Regularizer:
def get_config(self) -> dict[str, Any]: ...
@classmethod
def from_config(cls, config: dict[str, Any]) -> Self: ...
def __call__(self, __x: Tensor) -> Tensor: ...
def __call__(self, x: Tensor, /) -> Tensor: ...
_Regularizer: TypeAlias = str | dict[str, Any] | Regularizer | None # noqa: Y047