Skip to content

Commit 981bd8e

Browse files
authored
Remove pytype workarounds from third-party stubs (#14471)
1 parent 7e16c80 commit 981bd8e

File tree

6 files changed

+10
-17
lines changed

6 files changed

+10
-17
lines changed

stubs/django-import-export/import_export/templatetags/import_export_tags.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ from django.template import Library
44

55
register: Library
66

7-
# @register.simple_tag # commented out for pytype
7+
@register.simple_tag
88
def compare_values(value1: str, value2: str) -> LiteralString: ...

stubs/networkx/networkx/utils/__init__.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from networkx.utils.backends import *
2-
from networkx.utils.backends import _dispatchable as _dispatchable # for pytype to see the re-export in networkx/__init__.py
32
from networkx.utils.configs import *
43
from networkx.utils.configs import NetworkXConfig
54
from networkx.utils.decorators import *
65
from networkx.utils.heaps import *
76
from networkx.utils.misc import *
8-
from networkx.utils.misc import _clear_cache as _clear_cache # for pytype to see the re-export in networkx/__init__.py
97
from networkx.utils.random_sequence import *
108
from networkx.utils.rcm import *
119
from networkx.utils.union_find import *

stubs/seaborn/seaborn/_core/groupby.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ from pandas import DataFrame
77

88
# pandas._typing.AggFuncTypeFrame is partially Unknown
99
_AggFuncTypeBase: TypeAlias = Callable[..., Incomplete] | str | ufunc
10-
# Using Hashable instead of HashableT to work around pytype issue
1110
_AggFuncTypeDictFrame: TypeAlias = Mapping[Hashable, _AggFuncTypeBase | list[_AggFuncTypeBase]]
1211
_AggFuncTypeFrame: TypeAlias = _AggFuncTypeBase | list[_AggFuncTypeBase] | _AggFuncTypeDictFrame
1312

stubs/seaborn/seaborn/_stats/aggregation.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Agg(Stat):
1111
@dataclass
1212
class Est(Stat):
1313
func: str | Callable[[Vector], float] = "mean"
14-
errorbar: str | tuple[str, float] = ... # ("ci", 95) # pytype parse error
14+
errorbar: str | tuple[str, float] = ("ci", 95)
1515
n_boot: int = 1000
1616
seed: int | None = None
1717

stubs/tensorflow/tensorflow/_aliases.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ from collections.abc import Iterable, Mapping, Sequence
55
from typing import Any, Protocol, TypeVar
66
from typing_extensions import TypeAlias
77

8-
import numpy # pytype needs the unaliased import to resolve DTypeLike
98
import numpy as np
109
import numpy.typing as npt
1110
import tensorflow as tf
@@ -55,7 +54,7 @@ SparseTensorCompatible: TypeAlias = TensorCompatible | tf.SparseTensor
5554
TensorOrArray: TypeAlias = tf.Tensor | AnyArray
5655

5756
ShapeLike: TypeAlias = tf.TensorShape | Iterable[ScalarTensorCompatible | None] | int | tf.Tensor
58-
DTypeLike: TypeAlias = DType | str | numpy.dtype[Any] | int
57+
DTypeLike: TypeAlias = DType | str | np.dtype[Any] | int
5958

6059
ContainerTensors: TypeAlias = ContainerGeneric[tf.Tensor]
6160
ContainerTensorsLike: TypeAlias = ContainerGeneric[TensorLike]

stubs/tensorflow/tensorflow/io/__init__.pyi

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,16 @@ class TFRecordWriter:
4848
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
4949
) -> None: ...
5050

51-
# Also defaults are missing here because pytype crashes when a default is present reported
52-
# in this [issue](https://github.com/google/pytype/issues/1410#issue-1669793588). After
53-
# next release the defaults can be added back.
5451
class FixedLenFeature(NamedTuple):
5552
shape: ShapeLike
5653
dtype: DTypeLike
57-
default_value: TensorCompatible | None = ...
54+
default_value: TensorCompatible | None = None
5855

5956
class FixedLenSequenceFeature(NamedTuple):
6057
shape: ShapeLike
6158
dtype: DTypeLike
62-
allow_missing: bool = ...
63-
default_value: TensorCompatible | None = ...
59+
allow_missing: bool = False
60+
default_value: TensorCompatible | None = None
6461

6562
class VarLenFeature(NamedTuple):
6663
dtype: DTypeLike
@@ -70,7 +67,7 @@ class SparseFeature(NamedTuple):
7067
value_key: str
7168
dtype: DTypeLike
7269
size: int | list[int]
73-
already_sorted: bool = ...
70+
already_sorted: bool = False
7471

7572
class RaggedFeature(NamedTuple):
7673
# Mypy doesn't support nested NamedTuples, but at runtime they actually do use
@@ -94,12 +91,12 @@ class RaggedFeature(NamedTuple):
9491
length: int
9592

9693
dtype: DTypeLike
97-
value_key: str | None = ...
94+
value_key: str | None = None
9895
partitions: tuple[ # type: ignore[name-defined]
9996
RowSplits | RowLengths | RowStarts | RowLimits | ValueRowIds | UniformRowLength, ...
100-
] = ...
97+
] = ()
10198
row_splits_dtype: DTypeLike = ...
102-
validate: bool = ...
99+
validate: bool = False
103100

104101
def parse_example(
105102
serialized: TensorCompatible, features: _FeatureSpecs, example_names: Iterable[str] | None = None, name: str | None = None

0 commit comments

Comments
 (0)