Skip to content

Commit

Permalink
Enable pytype checking (internally) for Python modules and tests.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 517086504
  • Loading branch information
Marvin182 authored and copybara-github committed Mar 16, 2023
1 parent 5e60cb1 commit 5391813
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 0 additions & 2 deletions python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ py_test(
name = "array_record_module_test",
srcs = ["array_record_module_test.py"],
data = [":array_record_module.so"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"@com_google_absl_py//absl/testing:absltest",
],
Expand Down
2 changes: 1 addition & 1 deletion python/array_record_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __getitem__(self, record_keys: Sequence[int]) -> Sequence[T]:


def _run_in_parallel(
function: Callable[[Any], T],
function: Callable[..., T],
list_of_kwargs_to_function: Sequence[Mapping[str, Any]],
num_workers: int,
) -> List[T]:
Expand Down
18 changes: 7 additions & 11 deletions python/array_record_data_source_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,6 +15,7 @@

from concurrent import futures
import dataclasses
import os
import pathlib
from unittest import mock

Expand Down Expand Up @@ -95,14 +95,18 @@ def test_array_record_data_source_random_order(self):

def test_array_record_data_source_file_instructions(self):
file_instruction_one = DummyFileInstruction(
filename=self.testdata_dir / "digits.array_record-00000-of-00002",
filename=os.fspath(
self.testdata_dir / "digits.array_record-00000-of-00002"
),
skip=2,
take=1,
examples_in_shard=3,
)

file_instruction_two = DummyFileInstruction(
filename=self.testdata_dir / "digits.array_record-00001-of-00002",
filename=os.fspath(
self.testdata_dir / "digits.array_record-00001-of-00002"
),
skip=2,
take=2,
examples_in_shard=99,
Expand Down Expand Up @@ -162,14 +166,6 @@ def test_array_record_source_reader_idx_and_position_negative_idx(self):
with self.assertRaises(ValueError):
ar._reader_idx_and_position(len(ar))

def test_array_record_source_invalid_type(self):
with self.assertRaises(ValueError):
array_record_data_source.ArrayRecordDataSource(
{
"data": self.testdata_dir / "digits.array_record-00000-of-00001",
}
)

def test_array_record_source_empty_sequence(self):
with self.assertRaises(ValueError):
array_record_data_source.ArrayRecordDataSource([])
Expand Down

0 comments on commit 5391813

Please sign in to comment.