Repository: huggingface/diffusers (branch: refactor-single-file)
Commit date: 2024-01-19T08:16:52Z

Workflow file: .github/workflows/pr_quality.yml (Run code quality checks)
name: Run code quality checks

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  check_code_quality:
    runs-on: ubuntu-latest
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.8"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install .[quality]
      - name: Check quality
        run: |
          ruff check examples tests src utils scripts
          ruff format examples tests src utils scripts --check

  check_repository_consistency:
    runs-on: ubuntu-latest
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.8"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install .[quality]
      - name: Check quality
        run: |
          python utils/check_copies.py
          python utils/check_dummies.py
          make deps_table_check_updated

env:
  PIP_INDEX_URL: http://localhost:8629/2024-01-19
  UV_INDEX_URL: http://localhost:8629/2024-01-19


Failed build logs:
step_name: check_code_quality/5_Check quality.txt
log: ##[group]Run ruff check examples tests src utils scripts
[36;1mruff check examples tests src utils scripts[0m
[36;1mruff format examples tests src utils scripts --check[0m
shell: /usr/bin/bash -e {0}
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.8.18/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.8.18/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.8.18/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.8.18/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.8.18/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.18/x64/lib
##[endgroup]
src/diffusers/loaders/single_file_utils.py:23:8: F401 [*] `torch` imported but unused
src/diffusers/loaders/single_file_utils.py:25:44: F401 [*] `safetensors.torch.load_file` imported but unused
Found 2 errors.
[*] 2 fixable with the `--fix` option.
##[error]Process completed with exit code 1.


Changed files:
src/diffusers/loaders/single_file_utils.py

Fix diff:
diff --git a/src/diffusers/loaders/single_file_utils.py b/src/diffusers/loaders/single_file_utils.py
index 55b438b036..4dc4c71013 100644
--- a/src/diffusers/loaders/single_file_utils.py
+++ b/src/diffusers/loaders/single_file_utils.py
@@ -20,9 +20,7 @@ from contextlib import nullcontext
 from io import BytesIO
 
 import requests
-import torch
 import yaml
-from safetensors.torch import load_file as safe_load
 from transformers import (
     CLIPTextConfig,
     CLIPTextModel,
@@ -1117,7 +1115,9 @@ def create_text_encoders_and_tokenizers_from_ldm(
     elif model_type == "FrozenCLIPEmbedder":
         try:
             config_name = "openai/clip-vit-large-patch14"
-            text_encoder = create_text_encoder_from_ldm_clip_checkpoint(config_name, checkpoint, local_files_only=local_files_only)
+            text_encoder = create_text_encoder_from_ldm_clip_checkpoint(
+                config_name, checkpoint, local_files_only=local_files_only
+            )
             tokenizer = CLIPTokenizer.from_pretrained(config_name, local_files_only=local_files_only)
 
         except Exception:
@@ -1159,7 +1159,9 @@ def create_text_encoders_and_tokenizers_from_ldm(
         try:
             config_name = "openai/clip-vit-large-patch14"
             tokenizer = CLIPTokenizer.from_pretrained(config_name, local_files_only=local_files_only)
-            text_encoder = create_text_encoder_from_ldm_clip_checkpoint(config_name, checkpoint, local_files_only=local_files_only)
+            text_encoder = create_text_encoder_from_ldm_clip_checkpoint(
+                config_name, checkpoint, local_files_only=local_files_only
+            )
 
         except Exception:
             raise ValueError(