Skip to content

Commit dd5f7b3

Browse files
committed
try to fix typing
1 parent 80cc040 commit dd5f7b3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

autointent/_callbacks/tensorboard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self) -> None:
1616
Raises an ImportError if neither are installed.
1717
"""
1818
try:
19-
from torch.utils.tensorboard import SummaryWriter # type: ignore[attr-defined]
19+
from torch.utils.tensorboard import SummaryWriter
2020

2121
self.writer = SummaryWriter
2222
except ImportError:

autointent/_dump_tools/unit_dumpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ def load(path: Path, **kwargs: Any) -> PeftModel: # noqa: ANN401, ARG004
228228
if (path / "ptuning").exists():
229229
# prompt learning model
230230
ptuning_path = path / "ptuning"
231-
model = AutoModelForSequenceClassification.from_pretrained(ptuning_path / "base_model") # type: ignore[no-untyped-call]
231+
model = AutoModelForSequenceClassification.from_pretrained(ptuning_path / "base_model")
232232
return PeftModel.from_pretrained(model, ptuning_path / "peft")
233233
if (path / "lora").exists():
234234
# merged lora model
235235
lora_path = path / "lora"
236-
return AutoModelForSequenceClassification.from_pretrained(lora_path) # type: ignore[no-untyped-call,no-any-return]
236+
return AutoModelForSequenceClassification.from_pretrained(lora_path)
237237
msg = f"Invalid PeftModel directory structure at {path}. Expected 'ptuning' or 'lora' subdirectory."
238238
raise ValueError(msg)
239239

@@ -252,7 +252,7 @@ def dump(obj: PreTrainedModel, path: Path, exists_ok: bool) -> None:
252252

253253
@staticmethod
254254
def load(path: Path, **kwargs: Any) -> PreTrainedModel: # noqa: ANN401, ARG004
255-
return AutoModelForSequenceClassification.from_pretrained(path) # type: ignore[no-untyped-call,no-any-return]
255+
return AutoModelForSequenceClassification.from_pretrained(path)
256256

257257
@classmethod
258258
def check_isinstance(cls, obj: Any) -> bool: # noqa: ANN401
@@ -269,7 +269,7 @@ def dump(obj: PreTrainedTokenizer | PreTrainedTokenizerFast, path: Path, exists_
269269

270270
@staticmethod
271271
def load(path: Path, **kwargs: Any) -> PreTrainedTokenizer | PreTrainedTokenizerFast: # noqa: ANN401, ARG004
272-
return AutoTokenizer.from_pretrained(path) # type: ignore[no-any-return]
272+
return AutoTokenizer.from_pretrained(path) # type: ignore[no-any-return,no-untyped-call]
273273

274274
@classmethod
275275
def check_isinstance(cls, obj: Any) -> bool: # noqa: ANN401

autointent/modules/scoring/_bert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _initialize_model(self) -> Any: # noqa: ANN401
128128
label2id = {i: i for i in range(self._n_classes)}
129129
id2label = {i: i for i in range(self._n_classes)}
130130

131-
return AutoModelForSequenceClassification.from_pretrained( # type: ignore[no-untyped-call]
131+
return AutoModelForSequenceClassification.from_pretrained(
132132
self.classification_model_config.model_name,
133133
trust_remote_code=self.classification_model_config.trust_remote_code,
134134
num_labels=self._n_classes,
@@ -144,7 +144,7 @@ def fit(
144144
) -> None:
145145
self._validate_task(labels)
146146

147-
self._tokenizer = AutoTokenizer.from_pretrained(self.classification_model_config.model_name)
147+
self._tokenizer = AutoTokenizer.from_pretrained(self.classification_model_config.model_name) # type: ignore[no-untyped-call]
148148
self._model = self._initialize_model()
149149
tokenized_dataset = self._get_tokenized_dataset(utterances, labels)
150150
self._train(tokenized_dataset)

0 commit comments

Comments
 (0)