Check Scala output paths for the current generation run.
(
graph: List[Tuple[Path, Schema]],
grpc: bool = False,
)
| 361 | |
| 362 | |
| 363 | def validate_scala_output_paths( |
| 364 | graph: List[Tuple[Path, Schema]], |
| 365 | grpc: bool = False, |
| 366 | ) -> bool: |
| 367 | """Check Scala output paths for the current generation run.""" |
| 368 | outputs: Dict[str, List[str]] = {} |
| 369 | for path, schema in graph: |
| 370 | for output_path, owner in scala_output_paths(schema, include_services=grpc): |
| 371 | outputs.setdefault(output_path, []).append(f"{path} {owner}") |
| 372 | collisions = { |
| 373 | output_path: paths for output_path, paths in outputs.items() if len(paths) > 1 |
| 374 | } |
| 375 | if not collisions: |
| 376 | return True |
| 377 | details = ", ".join( |
| 378 | f"{output_path}: {', '.join(paths)}" |
| 379 | for output_path, paths in sorted(collisions.items()) |
| 380 | ) |
| 381 | print( |
| 382 | "Error: Scala generated file path collision; rename schema files, " |
| 383 | f"schema types, or services, or use distinct Scala packages. Collisions: {details}", |
| 384 | file=sys.stderr, |
| 385 | ) |
| 386 | return False |
| 387 | |
| 388 | |
| 389 | def validate_scala_generation( |
no test coverage detected