mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-10 18:36:31 +08:00
Remove pytype workarounds from third-party stubs (#14471)
This commit is contained in:
@@ -5,7 +5,6 @@ from collections.abc import Iterable, Mapping, Sequence
|
||||
from typing import Any, Protocol, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
import numpy # pytype needs the unaliased import to resolve DTypeLike
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
import tensorflow as tf
|
||||
@@ -55,7 +54,7 @@ SparseTensorCompatible: TypeAlias = TensorCompatible | tf.SparseTensor
|
||||
TensorOrArray: TypeAlias = tf.Tensor | AnyArray
|
||||
|
||||
ShapeLike: TypeAlias = tf.TensorShape | Iterable[ScalarTensorCompatible | None] | int | tf.Tensor
|
||||
DTypeLike: TypeAlias = DType | str | numpy.dtype[Any] | int
|
||||
DTypeLike: TypeAlias = DType | str | np.dtype[Any] | int
|
||||
|
||||
ContainerTensors: TypeAlias = ContainerGeneric[tf.Tensor]
|
||||
ContainerTensorsLike: TypeAlias = ContainerGeneric[TensorLike]
|
||||
|
||||
@@ -48,19 +48,16 @@ class TFRecordWriter:
|
||||
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
# Also defaults are missing here because pytype crashes when a default is present reported
|
||||
# in this [issue](https://github.com/google/pytype/issues/1410#issue-1669793588). After
|
||||
# next release the defaults can be added back.
|
||||
class FixedLenFeature(NamedTuple):
|
||||
shape: ShapeLike
|
||||
dtype: DTypeLike
|
||||
default_value: TensorCompatible | None = ...
|
||||
default_value: TensorCompatible | None = None
|
||||
|
||||
class FixedLenSequenceFeature(NamedTuple):
|
||||
shape: ShapeLike
|
||||
dtype: DTypeLike
|
||||
allow_missing: bool = ...
|
||||
default_value: TensorCompatible | None = ...
|
||||
allow_missing: bool = False
|
||||
default_value: TensorCompatible | None = None
|
||||
|
||||
class VarLenFeature(NamedTuple):
|
||||
dtype: DTypeLike
|
||||
@@ -70,7 +67,7 @@ class SparseFeature(NamedTuple):
|
||||
value_key: str
|
||||
dtype: DTypeLike
|
||||
size: int | list[int]
|
||||
already_sorted: bool = ...
|
||||
already_sorted: bool = False
|
||||
|
||||
class RaggedFeature(NamedTuple):
|
||||
# Mypy doesn't support nested NamedTuples, but at runtime they actually do use
|
||||
@@ -94,12 +91,12 @@ class RaggedFeature(NamedTuple):
|
||||
length: int
|
||||
|
||||
dtype: DTypeLike
|
||||
value_key: str | None = ...
|
||||
value_key: str | None = None
|
||||
partitions: tuple[ # type: ignore[name-defined]
|
||||
RowSplits | RowLengths | RowStarts | RowLimits | ValueRowIds | UniformRowLength, ...
|
||||
] = ...
|
||||
] = ()
|
||||
row_splits_dtype: DTypeLike = ...
|
||||
validate: bool = ...
|
||||
validate: bool = False
|
||||
|
||||
def parse_example(
|
||||
serialized: TensorCompatible, features: _FeatureSpecs, example_names: Iterable[str] | None = None, name: str | None = None
|
||||
|
||||
Reference in New Issue
Block a user