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

refactor: add typing #1742

Merged
merged 12 commits into from
Nov 21, 2024
9 changes: 5 additions & 4 deletions lightly/data/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from __future__ import annotations

import os
from typing import Any, Callable, Dict, Optional, Tuple
Expand Down Expand Up @@ -34,7 +35,7 @@
VIDEO_EXTENSIONS = (".mp4", ".mov", ".avi", ".mpg", ".hevc", ".m4v", ".webm", ".mpeg")


def _dir_contains_videos(root: str, extensions: Tuple[str, ...]) -> bool:
def _dir_contains_videos(root: str, extensions: tuple[str, ...]) -> bool:
"""Checks whether the directory contains video files.

Args:
Expand All @@ -48,7 +49,7 @@ def _dir_contains_videos(root: str, extensions: Tuple[str, ...]) -> bool:
return any(f.name.lower().endswith(extensions) for f in scan_dir)


def _contains_videos(root: str, extensions: Tuple[str, ...]) -> bool:
def _contains_videos(root: str, extensions: tuple[str, ...]) -> bool:
"""Checks whether the directory or any subdirectory contains video files.

Args:
Expand Down Expand Up @@ -92,8 +93,8 @@ def _contains_subdirs(root: str) -> bool:
def _load_dataset_from_folder(
root: str,
transform: Callable[[Any], Any],
is_valid_file: Optional[Callable[[str], bool]] = None,
tqdm_args: Optional[Dict[str, Any]] = None,
is_valid_file: Callable[[str], bool] | None,
tqdm_args: dict[str, Any] | None,
num_workers_video_frame_counting: int = 0,
) -> datasets.VisionDataset:
"""Initializes a dataset from a folder.
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ exclude = '''(?x)(
lightly/data/dataset.py |
lightly/data/collate.py |
lightly/data/_image.py |
lightly/data/_helpers.py |
lightly/data/_image_loaders.py |
lightly/data/_video.py |
lightly/data/multi_view_collate.py |
Expand Down