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

Fix compatibility issue with cPython<=3.11.3 #2416

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion src/anomalib/data/utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import os
import re
import sys
import tarfile
from collections.abc import Iterable
from dataclasses import dataclass
Expand Down Expand Up @@ -231,7 +232,11 @@ def safe_extract(tar_file: TarFile, root: Path, members: list[TarInfo]) -> None:
for member in members:
# check if the file already exists
if not (root / member.name).exists():
tar_file.extract(member, root, filter="data")
if sys.version_info[:3] >= (3, 11, 4):
# filter argument only works with python>=3.11.4
tar_file.extract(member, root, filter="data")
else:
tar_file.extract(member, root)


def generate_hash(file_path: str | Path, algorithm: str = "sha256") -> str:
Expand Down