Skip to content

Commit cf0887f

Browse files
authored
Remove old Python code (#41226)
Signed-off-by: Yuanyuan Chen <[email protected]>
1 parent 52f5eca commit cf0887f

File tree

3 files changed

+1
-18
lines changed

3 files changed

+1
-18
lines changed

src/transformers/hf_argparser.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,6 @@ def _add_dataclass_arguments(self, dtype: DataClassType):
262262
"removing line of `from __future__ import annotations` which opts in Postponed "
263263
"Evaluation of Annotations (PEP 563)"
264264
)
265-
except TypeError as ex:
266-
# Remove this block when we drop Python 3.9 support
267-
if sys.version_info[:2] < (3, 10) and "unsupported operand type(s) for |" in str(ex):
268-
python_version = ".".join(map(str, sys.version_info[:3]))
269-
raise RuntimeError(
270-
f"Type resolution failed for {dtype} on Python {python_version}. Try removing "
271-
"line of `from __future__ import annotations` which opts in union types as "
272-
"`X | Y` (PEP 604) via Postponed Evaluation of Annotations (PEP 563). To "
273-
"support Python versions that lower than 3.10, you need to use "
274-
"`typing.Union[X, Y]` instead of `X | Y` and `typing.Optional[X]` instead of "
275-
"`X | None`."
276-
) from ex
277-
raise
278265

279266
for field in dataclasses.fields(dtype):
280267
if not field.init:

src/transformers/models/idefics3/processing_idefics3.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ class Idefics3ProcessorKwargs(ProcessingKwargs, total=False):
108108
}
109109

110110

111-
Idefics3ProcessorKwargs.__annotations__["images_kwargs"] = Idefics3ImagesKwargs # python 3.8 compatibility
112-
113-
114111
class Idefics3Processor(ProcessorMixin):
115112
r"""
116113
Constructs a Idefics3 processor which wraps a LLama tokenizer and Idefics3 image processor into a single processor.

tests/peft_integration/test_peft_integration.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,8 @@ def test_peft_from_pretrained_missing_keys_warning(self):
715715

716716
# Here we need to adjust the key name a bit to account for PEFT-specific naming.
717717
# 1. Remove PEFT-specific prefix
718-
# If merged after dropping Python 3.8, we can use: key = key.removeprefix(peft_prefix)
719718
peft_prefix = "base_model.model."
720-
key = key[len(peft_prefix) :]
719+
key = key.removeprefix(peft_prefix)
721720
# 2. Insert adapter name
722721
prefix, _, suffix = key.rpartition(".")
723722
key = f"{prefix}.other.{suffix}"

0 commit comments

Comments
 (0)