MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / suggest_path_corrections

Method suggest_path_corrections

scripts/openapi.py:2491–2521  ·  view source on GitHub ↗
(self, paths: dict[str, Any], implemented_paths: dict[str, Any])

Source from the content-addressed store, hash-verified

2489 return False
2490
2491 def suggest_path_corrections(self, paths: dict[str, Any], implemented_paths: dict[str, Any]):
2492 spec_paths = {(verb, path) for path, verbs in paths.items() for verb in verbs}
2493 impl_paths = {(verb.lower(), path) for path, verbs in implemented_paths.items() for verb in verbs}
2494 unspec_paths = impl_paths - spec_paths
2495 impl_spec_paths = spec_paths.intersection(impl_paths)
2496 print(
2497 f"There are {len(impl_spec_paths)} out of {len(spec_paths)} verbs ({len(impl_spec_paths) * 100 // len(spec_paths)}%) implemented"
2498 )
2499 print(f"There are {len(unspec_paths)} verbs unknown to the OpenAPI spec")
2500 if self.verbose:
2501 for verb, path in sorted(list(unspec_paths)):
2502 print(f"- {verb} {path}")
2503 print()
2504
2505 spec_paths = {path for (verb, path) in spec_paths}
2506 impl_paths = {path for (verb, path) in impl_paths}
2507 unspec_paths = impl_paths - spec_paths
2508 impl_spec_paths = spec_paths.intersection(impl_paths)
2509 print(
2510 f"There are {len(impl_spec_paths)} out of {len(spec_paths)} paths ({len(impl_spec_paths) * 100 // len(spec_paths)}%) implemented"
2511 )
2512 print(f"There are {len(unspec_paths)} paths unknown to the OpenAPI spec")
2513 if self.verbose:
2514
2515 def fingerprint(path: str) -> str:
2516 return re.sub("[{][^}]+[}]", "{}", path.rstrip("/"))
2517
2518 spec_fingerprints = {fingerprint(path): path for path in spec_paths}
2519 for path in sorted(list(unspec_paths)):
2520 print(f"- {path}: {spec_fingerprints.get(fingerprint(path), ' ')}")
2521 print()
2522
2523 def suggest_method_names(self, verb: str, prefix_path: str, path: str, spec: dict[str, Any]) -> list[str]:
2524 suffix_path = path.replace("-", "_")[len(prefix_path) + 1 :]

Callers 1

suggest_pathsMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected