MCPcopy Create free account
hub / github.com/apache/fory / validate_kotlin_output_paths

Function validate_kotlin_output_paths

compiler/fory_compiler/cli.py:281–304  ·  view source on GitHub ↗

Check Kotlin output paths for the current generation run.

(
    graph: List[Tuple[Path, Schema]],
    grpc: bool = False,
)

Source from the content-addressed store, hash-verified

279
280
281def 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
307def validate_kotlin_generation(

Callers 1

Calls 4

kotlin_output_pathsFunction · 0.90
setdefaultMethod · 0.80
itemsMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected