Skip to content
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

remove redundant typing casts #8140

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion torchvision/prototype/tv_tensors/_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def to_categories(self) -> Any:
if self.categories is None:
raise RuntimeError("Label does not have categories")

return tree_map(lambda idx: self.categories[idx], self.tolist())
return tree_map(lambda idx: self.categories[idx], self.tolist()) # type: ignore[index]


class OneHotLabel(_LabelBase):
Expand Down
4 changes: 1 addition & 3 deletions torchvision/transforms/v2/_geometry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math
import numbers
import warnings
from typing import Any, Callable, cast, Dict, List, Literal, Optional, Sequence, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Type, Union

import PIL.Image
import torch
Expand Down Expand Up @@ -241,10 +241,8 @@ def __init__(

if not isinstance(scale, Sequence):
raise TypeError("Scale should be a sequence")
scale = cast(Tuple[float, float], scale)
if not isinstance(ratio, Sequence):
raise TypeError("Ratio should be a sequence")
ratio = cast(Tuple[float, float], ratio)
if (scale[0] > scale[1]) or (ratio[0] > ratio[1]):
warnings.warn("Scale and ratio should be of kind (min, max)")

Expand Down
Loading