Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
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
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
pip3 install --pre torch -f "${{ steps.pytorch_channel.outputs.value }}"
- name: Install dependencies
run: |
pip3 install requests mypy==0.812 graphviz numpy
pip3 install requests mypy==0.981 graphviz numpy
- name: Build TorchData
run: |
python setup.py develop
Expand All @@ -64,7 +64,7 @@ jobs:
run: |
set -eux
STATUS=
if ! mypy --config=mypy.ini; then
if ! mypy --config=mypy.ini --enable-recursive-aliases --install-types --non-interactive; then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also like to point out that, --install-types --non-interactive will install the missing package stubs hence slower.

Quoting relevant part from the above documentation link :- This is somewhat slower than explicitly installing stubs before running mypy, since it may type check your code twice – the first time to find the missing stubs, and the second time to type check your code properly after mypy has installed the stubs.

I don't think downloading the package stubs would be a bottleneck; but if it is, then we could think of using cached installations. (just a suggestion)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for providing the idea. I think it's fine for now as torchdata is still a small package. We might want to investigate if we have noticed significant overhead.

STATUS=fail
fi
if [ -n "$STATUS" ]; then
Expand Down
2 changes: 1 addition & 1 deletion torchdata/datapipes/iter/util/randomsplitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(
self._rng = random.Random(self._seed)
self._lengths: List[int] = []

def draw(self) -> T:
def draw(self) -> T: # type: ignore
selected_key = self._rng.choices(self.keys, self.weights)[0]
index = self.key_to_index[selected_key]
self.weights[index] -= 1
Expand Down
2 changes: 1 addition & 1 deletion torchdata/datapipes/iter/util/tfrecordloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def prod(xs):
# Note, reccursive types not supported by mypy at the moment
# TODO(640): uncomment as soon as it becomes supported
# https://github.com/python/mypy/issues/731
# BinaryData = Union[str, List['BinaryData']]
BinaryData = Union[str, List["BinaryData"]]
TFRecordBinaryData = Union[str, List[str], List[List[str]], List[List[List[Any]]]]
TFRecordExampleFeature = Union[torch.Tensor, List[torch.Tensor], TFRecordBinaryData]
TFRecordExample = Dict[str, TFRecordExampleFeature]
Expand Down