Skip to content

Initial tensorflow stubs #8974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ignore missing stub
  • Loading branch information
Mehdi Drissi committed Jan 11, 2023
commit bb714f538583ee14c43da0624fa03a254b7b51aa
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[flake8]
per-file-ignores =
*.py: E203, E301, E302, E305, E501
*.pyi: B, E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y037
*.pyi: B, E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y011, Y037
# Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload.
# Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself.
# https://github.com/PyCQA/flake8/issues/1079
Expand Down
5 changes: 1 addition & 4 deletions stubs/tensorflow/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
version = "2.10.*"
requires = ["numpy"]

[tool.stubtest]
ignore_missing_stub = false
requires = ["numpy"]
6 changes: 3 additions & 3 deletions stubs/tensorflow/tensorflow/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from tensorflow.sparse import SparseTensor
# we will skip making Tensor generic. Also good type hints for shapes will
# run quickly into many places where type system is not strong enough today.
# So shape typing is probably not worth doing anytime soon.
_SliceT: TypeAlias = int | slice | None
_Slice: TypeAlias = int | slice | None

_FloatDataSequence: TypeAlias = Sequence[float] | Sequence[_FloatDataSequence]
_StrDataSequence: TypeAlias = Sequence[str] | Sequence[_StrDataSequence]
Expand Down Expand Up @@ -67,7 +67,7 @@ class Tensor:
def __le__(self, other: _TensorCompatible) -> Tensor: ...
def __lt__(self, other: _TensorCompatible) -> Tensor: ...
def __bool__(self) -> NoReturn: ...
def __getitem__(self, slice_spec: _SliceT | tuple[_SliceT, ...]) -> Tensor: ...
def __getitem__(self, slice_spec: _Slice | tuple[_Slice, ...]) -> Tensor: ...
def __len__(self) -> int: ...
# This only works for rank 0 tensors.
def __index__(self) -> int: ...
Expand All @@ -92,7 +92,7 @@ class RaggedTensor:
def __rmul__(self, other: RaggedTensor | float) -> RaggedTensor: ...
def __floordiv__(self, other: RaggedTensor | float) -> RaggedTensor: ...
def __truediv__(self, other: RaggedTensor | float) -> RaggedTensor: ...
def __getitem__(self, slice_spec: _SliceT | tuple[_SliceT, ...]) -> RaggedTensor: ...
def __getitem__(self, slice_spec: _Slice | tuple[_Slice, ...]) -> RaggedTensor: ...
def __getattr__(self, name: str) -> Incomplete: ...

class Operation:
Expand Down