Skip to content

Commit bc75bbc

Browse files
committed
Fix code formatting with ruff
1 parent aa1d426 commit bc75bbc

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/transformers/utils/hub.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,15 +414,15 @@ def cached_files(
414414
subfolder = ""
415415

416416
if local_files_only or is_offline_mode():
417-
cache_dirs_to_try= []
417+
cache_dirs_to_try = []
418418

419419
if cache_dir is not None:
420420
cache_dirs_to_try.append(cache_dir)
421421

422-
for env_var in ["HF_HOME","TRANSFORMERS_CACHE", "HF_HUB_CACHE"]:
423-
env_cache = os.environ.get(env_var)
424-
if env_cache and env_cache not in cache_dirs_to_try:
425-
cache_dirs_to_try.append(env_cache)
422+
for env_var in ["HF_HOME", "TRANSFORMERS_CACHE", "HF_HUB_CACHE"]:
423+
env_cache = os.environ.get(env_var)
424+
if env_cache and env_cache not in cache_dirs_to_try:
425+
cache_dirs_to_try.append(env_cache)
426426

427427
default_cache = default_cache_path
428428
if default_cache not in cache_dirs_to_try:

tests/utils/test.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ def guarded_socket(*args, **kwargs):
109109
if "NETWORK_ATTEMPTED" in result.stdout:
110110
self.fail(f"Network access attempted despite warm cache: {result.stdout}")
111111

112-
self.assertIn("OFFLINE_SUCCESS", result.stdout,
113-
f"Failed to load offline:\nSTDOUT: {result.stdout}\nSTDERR: {result.stderr}")
112+
self.assertIn(
113+
"OFFLINE_SUCCESS",
114+
result.stdout,
115+
f"Failed to load offline:\nSTDOUT: {result.stdout}\nSTDERR: {result.stderr}",
116+
)
114117
self.assertEqual(result.returncode, 0)
115118

116119
def test_pipeline_offline_after_subprocess_warm(self):
@@ -134,8 +137,9 @@ def test_pipeline_offline_after_subprocess_warm(self):
134137
print("WARMED")
135138
"""
136139

137-
result = subprocess.run([sys.executable, "-c", warm_script],
138-
capture_output=True, text=True, env=env, timeout=120)
140+
result = subprocess.run(
141+
[sys.executable, "-c", warm_script], capture_output=True, text=True, env=env, timeout=120
142+
)
139143
self.assertEqual(result.returncode, 0)
140144

141145
# Load offline
@@ -165,8 +169,9 @@ def no_socket(*args, **kwargs):
165169
exit(1)
166170
"""
167171

168-
result = subprocess.run([sys.executable, "-c", offline_script],
169-
capture_output=True, text=True, env=env, timeout=120)
172+
result = subprocess.run(
173+
[sys.executable, "-c", offline_script], capture_output=True, text=True, env=env, timeout=120
174+
)
170175

171176
self.assertNotIn("BLOCKED", result.stdout, "Network access attempted")
172177
self.assertIn("SUCCESS", result.stdout)

0 commit comments

Comments
 (0)