Skip to content

Commit 9fac463

Browse files
committed
Import Callable from collections.abc
Signed-off-by: Yuanyuan Chen <[email protected]>
1 parent cf0887f commit 9fac463

File tree

284 files changed

+562
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

284 files changed

+562
-307
lines changed

examples/modular-transformers/modeling_from_uppercase_model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# the file from the modular. If any change should be done, please apply the change to the
55
# modular_from_uppercase_model.py file directly. One of our CI enforces this.
66
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
7-
from typing import Callable, Optional, Union
7+
from collections.abc import Callable
8+
from typing import Optional, Union
89

910
import torch
1011
from torch import nn

examples/modular-transformers/modeling_global_indexing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# the file from the modular. If any change should be done, please apply the change to the
55
# modular_global_indexing.py file directly. One of our CI enforces this.
66
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
7-
from typing import Callable, Optional
7+
from collections.abc import Callable
8+
from typing import Optional
89

910
import torch
1011
from torch import nn

examples/modular-transformers/modeling_multimodal2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# modular_multimodal2.py file directly. One of our CI enforces this.
66
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
77

8-
from typing import Callable, Optional, Union
8+
from collections.abc import Callable
9+
from typing import Optional, Union
910

1011
import torch
1112
from torch import nn

examples/modular-transformers/modeling_my_new_model2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# the file from the modular. If any change should be done, please apply the change to the
55
# modular_my_new_model2.py file directly. One of our CI enforces this.
66
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
7-
from typing import Callable, Optional
7+
from collections.abc import Callable
8+
from typing import Optional
89

910
import torch
1011
from torch import nn

examples/modular-transformers/modeling_super.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# the file from the modular. If any change should be done, please apply the change to the
55
# modular_super.py file directly. One of our CI enforces this.
66
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
7-
from typing import Callable, Optional, Union
7+
from collections.abc import Callable
8+
from typing import Optional, Union
89

910
import torch
1011
from torch import nn

examples/modular-transformers/modeling_switch_function.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# modular_switch_function.py file directly. One of our CI enforces this.
66
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
77
# Note that llama and cohere have different definitions for rotate_half
8-
from typing import Callable, Optional
8+
from collections.abc import Callable
9+
from typing import Optional
910

1011
import torch
1112
from torch import nn

src/transformers/commands/add_new_model_like.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
import subprocess
1818
import textwrap
1919
from argparse import ArgumentParser, Namespace
20+
from collections.abc import Callable
2021
from datetime import date
2122
from pathlib import Path
22-
from typing import Any, Callable, Optional, Union
23+
from typing import Any, Optional, Union
2324

2425
from ..models.auto.configuration_auto import CONFIG_MAPPING_NAMES, MODEL_NAMES_MAPPING
2526
from ..models.auto.feature_extraction_auto import FEATURE_EXTRACTOR_MAPPING_NAMES

src/transformers/data/data_collator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import multiprocessing as mp
1616
import warnings
17-
from collections.abc import Mapping
17+
from collections.abc import Callable, Mapping
1818
from dataclasses import dataclass
1919
from random import randint
20-
from typing import Any, Callable, Optional, Union
20+
from typing import Any, Optional, Union
2121

2222
import numpy as np
2323

src/transformers/generation/configuration_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
import os
2020
import warnings
2121
from abc import ABC, abstractmethod
22+
from collections.abc import Callable
2223
from dataclasses import dataclass, is_dataclass
23-
from typing import TYPE_CHECKING, Any, Callable, Optional, Union
24+
from typing import TYPE_CHECKING, Any, Optional, Union
2425

2526
from .. import __version__
2627
from ..configuration_utils import PretrainedConfig

src/transformers/generation/logits_process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
import inspect
1717
import math
18-
from collections.abc import Iterable
19-
from typing import TYPE_CHECKING, Callable, Optional, Union
18+
from collections.abc import Callable, Iterable
19+
from typing import TYPE_CHECKING, Optional, Union
2020

2121
import numpy as np
2222
import torch

0 commit comments

Comments
 (0)