Skip to content

Commit 4147520

Browse files
authored
Ensure imports are sorted (#11)
1 parent 3a350a6 commit 4147520

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

protogen/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1560,9 +1560,10 @@ def print_import(self):
15601560

15611561
def _proto(self) -> google.protobuf.compiler.plugin_pb2.CodeGeneratorResponse.File:
15621562
if self._import_mark > -1:
1563+
sorted_imports = sorted(self._imports, key=lambda x: x._path)
15631564
lines = (
15641565
self._buf[: self._import_mark]
1565-
+ [f"import {p._path}" for p in self._imports]
1566+
+ [f"import {p._path}" for p in sorted_imports]
15661567
+ self._buf[self._import_mark :]
15671568
)
15681569
else:

0 commit comments

Comments
 (0)