Skip to content

Commit bd370c5

Browse files
committed
Fix pylint warnings
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
1 parent 46c6f01 commit bd370c5

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

src/transformers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,6 @@
770770
from .utils import is_torch_npu_available as is_torch_npu_available
771771
from .utils import is_torch_xla_available as is_torch_xla_available
772772
from .utils import is_torch_xpu_available as is_torch_xpu_available
773-
from .utils import logging as logging
774773

775774
# bitsandbytes config
776775
from .utils.quantization_config import AqlmConfig as AqlmConfig

src/transformers/generation/watermarking.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
from torch.nn import BCELoss
2525

2626
from ..modeling_utils import PreTrainedModel
27-
from ..utils import ModelOutput, is_torch_available, logging
27+
from ..utils import ModelOutput, logging
2828
from .configuration_utils import PretrainedConfig, WatermarkingConfig
29-
30-
31-
if is_torch_available():
32-
from .logits_process import SynthIDTextWatermarkLogitsProcessor, WatermarkLogitsProcessor
29+
from .logits_process import SynthIDTextWatermarkLogitsProcessor, WatermarkLogitsProcessor
3330

3431

3532
logger = logging.get_logger(__name__)

src/transformers/testing_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,10 +2516,10 @@ def check_json_file_has_correct_format(file_path):
25162516
else:
25172517
# otherwise make sure json has correct format (at least 3 lines)
25182518
assert len(lines) >= 3
2519-
# each key one line, indent should be 2, min length is 3
2519+
# each key one line, ident should be 2, min length is 3
25202520
assert lines[0].strip() == "{"
25212521
for line in lines[1:-1]:
2522-
left_indent = len(line) - len(line.lstrip())
2522+
left_indent = len(lines[1]) - len(lines[1].lstrip())
25232523
assert left_indent == 2
25242524
assert lines[-1].strip() == "}"
25252525

src/transformers/tokenization_utils_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ def _from_pretrained(
21382138
if template_file is None:
21392139
continue # I think this should never happen, but just in case
21402140
template_name = extra_chat_template.removeprefix("chat_template_")
2141-
with open(template_file) as chat_template_handle:
2141+
with open(template_file, "rt", encoding="utf8") as chat_template_handle:
21422142
chat_templates[template_name] = chat_template_handle.read()
21432143
if len(chat_templates) == 1 and "default" in chat_templates:
21442144
init_kwargs["chat_template"] = chat_templates["default"]

0 commit comments

Comments
 (0)