Skip to content

Update code to Python 3.7 compliance #5125

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 3 commits into from
Dec 27, 2021
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
4 changes: 2 additions & 2 deletions torchvision/datasets/_optical_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ def __init__(self, root, split="train", pass_name="clean", camera="left", transf
directions = ("into_future", "into_past")
for pass_name, camera, direction in itertools.product(passes, cameras, directions):
image_dirs = sorted(glob(str(root / pass_name / split / "*/*")))
image_dirs = sorted([Path(image_dir) / camera for image_dir in image_dirs])
image_dirs = sorted(Path(image_dir) / camera for image_dir in image_dirs)

flow_dirs = sorted(glob(str(root / "optical_flow" / split / "*/*")))
flow_dirs = sorted([Path(flow_dir) / direction / camera for flow_dir in flow_dirs])
flow_dirs = sorted(Path(flow_dir) / direction / camera for flow_dir in flow_dirs)

if not image_dirs or not flow_dirs:
raise FileNotFoundError(
Expand Down
2 changes: 1 addition & 1 deletion torchvision/datasets/food101.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(

self._labels = []
self._image_files = []
with open(self._meta_folder / f"{split}.json", "r") as f:
with open(self._meta_folder / f"{split}.json") as f:
metadata = json.loads(f.read())

self.classes = sorted(metadata.keys())
Expand Down
2 changes: 1 addition & 1 deletion torchvision/io/_video_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _validate_pts(pts_range: Tuple[int, int]) -> None:
assert (
pts_range[0] <= pts_range[1]
), """Start pts should not be smaller than end pts, got
start pts: {0:d} and end pts: {1:d}""".format(
start pts: {:d} and end pts: {:d}""".format(
pts_range[0],
pts_range[1],
)
Expand Down
2 changes: 1 addition & 1 deletion torchvision/models/optical_flow/raft.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class BottleneckBlock(nn.Module):
"""Slightly modified BottleNeck block (extra relu and biases)"""

def __init__(self, in_channels, out_channels, *, norm_layer, stride=1):
super(BottleneckBlock, self).__init__()
super().__init__()

# See note in ResidualBlock for the reason behind bias=True
self.convnormrelu1 = ConvNormActivation(
Expand Down