Skip to content

Commit 1d2ed14

Browse files
committed
Return sorted list from _get_large_files
1 parent 36b5751 commit 1d2ed14

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/fastapi_cloud_cli/commands/deploy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def _get_large_files(path: Path, threshold_mb: int) -> list[tuple[Path, int]]:
149149
if file_size >= threshold_bytes:
150150
large_files.append((filename.relative_to(path), file_size))
151151

152-
return large_files
152+
return sorted(large_files, key=lambda x: x[1], reverse=True)
153153

154154

155155
class Team(BaseModel):
@@ -834,8 +834,7 @@ def deploy(
834834
f"⚠️ Some uploaded files are larger than {large_file_threshold} MB ⚖️ :",
835835
tag="warning",
836836
)
837-
top_3 = sorted(large_files, key=lambda x: x[1], reverse=True)[:3]
838-
for fname, fsize in top_3:
837+
for fname, fsize in large_files[:3]:
839838
fsize_mb = fsize // (1024 * 1024)
840839
toolkit.print(f" • {fname} [yellow]({fsize_mb} MB)[/yellow]")
841840
is_more = len(large_files) > 3

tests/test_deploy_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ def test_get_large_files_returns_files_at_or_above_threshold(tmp_path: Path) ->
161161

162162
result = _get_large_files(tmp_path, threshold_mb=1)
163163

164-
assert sorted(result, key=lambda x: x[1]) == [
165-
(Path("big.bin"), 2 * 1024 * 1024),
164+
assert result == [
166165
(Path("subdir") / "huge.bin", 5 * 1024 * 1024),
166+
(Path("big.bin"), 2 * 1024 * 1024),
167167
]
168168

169169

0 commit comments

Comments
 (0)