Add @type_check_only to stub-only private classes in various third-party stubs (#15535)

This commit is contained in:
Semyon Moroz
2026-03-21 18:02:17 -04:00
committed by GitHub
parent 222da0600f
commit 282b1a838a
15 changed files with 56 additions and 18 deletions
+3 -1
View File
@@ -2,7 +2,7 @@
# Everything in this module is private for stubs. There is no runtime equivalent.
from collections.abc import Iterable, Mapping, Sequence
from typing import Any, Protocol, TypeVar
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -20,9 +20,11 @@ RaggedTensorLike: TypeAlias = tf.Tensor | tf.RaggedTensor
# _RaggedTensorLikeT = TypeVar("_RaggedTensorLikeT", tf.Tensor, tf.RaggedTensor)
Gradients: TypeAlias = tf.Tensor | tf.IndexedSlices
@type_check_only
class KerasSerializable1(Protocol):
def get_config(self) -> dict[str, Any]: ...
@type_check_only
class KerasSerializable2(Protocol):
__name__: str
@@ -1,8 +1,9 @@
import typing_extensions
from typing import TypedDict
from typing import TypedDict, type_check_only
from tensorflow.config import PhysicalDevice
@type_check_only
class _MemoryInfo(TypedDict):
current: int
peak: int