Skip to content

Commit 9eb9385

Browse files
authored
Clean up Unpack imports (#33631)
clean up Unpack imports
1 parent 78b2929 commit 9eb9385

File tree

6 files changed

+6
-44
lines changed

6 files changed

+6
-44
lines changed

src/transformers/models/grounding_dino/processing_grounding_dino.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,12 @@
1717
"""
1818

1919
import pathlib
20-
import sys
2120
from typing import Dict, List, Optional, Tuple, Union
2221

2322
from ...image_processing_utils import BatchFeature
2423
from ...image_transforms import center_to_corners_format
2524
from ...image_utils import AnnotationFormat, ImageInput
26-
from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin
27-
28-
29-
if sys.version_info >= (3, 11):
30-
from typing import Unpack
31-
else:
32-
from typing_extensions import Unpack
33-
25+
from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, Unpack
3426
from ...tokenization_utils_base import BatchEncoding, PreTokenizedInput, TextInput
3527
from ...utils import TensorType, is_torch_available
3628

src/transformers/models/llava/processing_llava.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@
1616
Processor class for Llava.
1717
"""
1818

19-
import sys
2019
from typing import List, Union
2120

2221
from ...feature_extraction_utils import BatchFeature
2322
from ...image_utils import ImageInput, get_image_size, to_numpy_array
24-
from ...processing_utils import ProcessingKwargs, ProcessorMixin, _validate_images_text_input_order
23+
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack, _validate_images_text_input_order
2524
from ...tokenization_utils_base import PreTokenizedInput, TextInput
2625
from ...utils import logging
2726

2827

29-
if sys.version_info >= (3, 11):
30-
from typing import Unpack
31-
else:
32-
from typing_extensions import Unpack
33-
3428
logger = logging.get_logger(__name__)
3529

3630

src/transformers/models/llava_onevision/processing_llava_onevision.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,12 @@
1818

1919
import math
2020
import os
21-
import sys
2221
from typing import Iterable, List, Union
2322

24-
25-
if sys.version_info >= (3, 11):
26-
from typing import Unpack
27-
else:
28-
from typing_extensions import Unpack
29-
3023
from ...feature_extraction_utils import BatchFeature
3124
from ...image_processing_utils import select_best_resolution
3225
from ...image_utils import ImageInput, VideoInput, get_image_size, to_numpy_array
33-
from ...processing_utils import (
34-
ProcessingKwargs,
35-
ProcessorMixin,
36-
)
26+
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
3727
from ...tokenization_utils_base import PreTokenizedInput, TextInput
3828
from ...utils import logging
3929
from ..auto import AutoImageProcessor

src/transformers/models/pixtral/processing_pixtral.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@
1616
Processor class for Pixtral.
1717
"""
1818

19-
import sys
2019
from typing import List, Union
2120

2221
from ...feature_extraction_utils import BatchFeature
2322
from ...image_utils import ImageInput, is_valid_image, load_image
24-
from ...processing_utils import ProcessingKwargs, ProcessorMixin, _validate_images_text_input_order
23+
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack, _validate_images_text_input_order
2524
from ...tokenization_utils_base import PreTokenizedInput, TextInput
2625
from ...utils import is_torch_device, is_torch_dtype, is_torch_tensor, logging, requires_backends
2726

2827

29-
if sys.version_info >= (3, 11):
30-
from typing import Unpack
31-
else:
32-
from typing_extensions import Unpack
33-
3428
logger = logging.get_logger(__name__)
3529

3630

src/transformers/models/qwen2_vl/processing_qwen2_vl.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,9 @@
2323

2424
from typing import List, Union
2525

26-
27-
try:
28-
from typing import Unpack
29-
except ImportError:
30-
from typing_extensions import Unpack
31-
3226
from ...feature_extraction_utils import BatchFeature
3327
from ...image_utils import ImageInput, VideoInput
34-
from ...processing_utils import (
35-
ProcessingKwargs,
36-
ProcessorMixin,
37-
)
28+
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
3829
from ...tokenization_utils_base import PreTokenizedInput, TextInput
3930
from ...utils import logging
4031

tests/test_processing_common.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import numpy as np
2222

2323
from transformers.models.auto.processing_auto import processor_class_from_name
24+
from transformers.processing_utils import Unpack
2425
from transformers.testing_utils import (
2526
check_json_file_has_correct_format,
2627
require_torch,

0 commit comments

Comments
 (0)