Check Kotlin output paths for the current generation run.
(
graph: List[Tuple[Path, Schema]],
grpc: bool = False,
)
| 279 | |
| 280 | |
| 281 | def validate_kotlin_output_paths( |
| 282 | graph: List[Tuple[Path, Schema]], |
| 283 | grpc: bool = False, |
| 284 | ) -> bool: |
| 285 | """Check Kotlin output paths for the current generation run.""" |
| 286 | outputs: Dict[str, List[str]] = {} |
| 287 | for path, schema in graph: |
| 288 | for output_path, owner in kotlin_output_paths(schema, include_services=grpc): |
| 289 | outputs.setdefault(output_path, []).append(f"{path} {owner}") |
| 290 | collisions = { |
| 291 | output_path: paths for output_path, paths in outputs.items() if len(paths) > 1 |
| 292 | } |
| 293 | if not collisions: |
| 294 | return True |
| 295 | details = ", ".join( |
| 296 | f"{output_path}: {', '.join(paths)}" |
| 297 | for output_path, paths in sorted(collisions.items()) |
| 298 | ) |
| 299 | print( |
| 300 | "Error: Kotlin generated file path collision; rename schema files or " |
| 301 | f"schema types, or use distinct Kotlin packages. Collisions: {details}", |
| 302 | file=sys.stderr, |
| 303 | ) |
| 304 | return False |
| 305 | |
| 306 | |
| 307 | def validate_kotlin_generation( |
no test coverage detected