Skip to content

Commit 13bfe61

Browse files
committed
Make file processing order deterministic
By using `set` for specifying files in queue we loose the order in which the files will be processed (in `missing_files` var).
1 parent dda0b55 commit 13bfe61

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

bump_pydantic/main.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import time
66
import traceback
7+
from collections import deque
78
from pathlib import Path
89
from typing import Any, Dict, Iterable, List, Set, Tuple, Type, TypeVar, Union
910

@@ -84,7 +85,7 @@ def main(
8485
scratch: dict[str, Any] = {}
8586
with Progress(*Progress.get_default_columns(), transient=True) as progress:
8687
task = progress.add_task(description="Looking for Pydantic Models...", total=len(files))
87-
queue: List[str] = [files[0]]
88+
queue = deque(files)
8889
visited: Set[str] = set()
8990

9091
while queue:
@@ -111,11 +112,7 @@ def main(
111112
# Queue logic
112113
next_file = visitor.next_file(visited)
113114
if next_file is not None:
114-
queue.append(next_file)
115-
116-
missing_files = set(files) - visited
117-
if not queue and missing_files:
118-
queue.append(next(iter(missing_files)))
115+
queue.appendleft(next_file)
119116

120117
start_time = time.time()
121118

0 commit comments

Comments
 (0)