(
class_name: str, index: dict[str, Any] | None = None, github_parent_path: str = ""
)
| 253 | |
| 254 | @staticmethod |
| 255 | def from_class_name( |
| 256 | class_name: str, index: dict[str, Any] | None = None, github_parent_path: str = "" |
| 257 | ) -> GithubClass: |
| 258 | if github_parent_path and not github_parent_path.endswith("/"): |
| 259 | github_parent_path = f"{github_parent_path}/" |
| 260 | if "." in class_name: |
| 261 | full_class_name = class_name |
| 262 | package, module, class_name = full_class_name.split(".", 2) |
| 263 | if index is not None: |
| 264 | clazz = GithubClass.from_class_name(class_name, index) |
| 265 | if clazz.package != package or clazz.module != module or clazz.name != class_name: |
| 266 | raise ValueError(f"Class mismatch: {full_class_name} vs {clazz}") |
| 267 | return clazz |
| 268 | else: |
| 269 | return GithubClass( |
| 270 | ids=[], |
| 271 | package="github", |
| 272 | module=class_name, |
| 273 | name=class_name, |
| 274 | filename=f"{github_parent_path}{package}/{module}.py", |
| 275 | test_filename=f"{github_parent_path}tests/{module}.py", |
| 276 | bases=[], |
| 277 | inheritance=[], |
| 278 | methods={}, |
| 279 | properties={}, |
| 280 | schemas=[], |
| 281 | inherited_schemas=[], |
| 282 | docstring="", |
| 283 | ) |
| 284 | else: |
| 285 | if index is not None: |
| 286 | classes = index.get("classes", {}) |
| 287 | if class_name not in classes: |
| 288 | raise ValueError(f"Unknown class {class_name}") |
| 289 | cls = classes.get(class_name) |
| 290 | if any(key not in cls for key in ["package", "module", "name"]): |
| 291 | raise KeyError(f"Missing package, module or name in {cls}") |
| 292 | return GithubClass(**cls) |
| 293 | else: |
| 294 | return GithubClass.from_class_name( |
| 295 | f"github.{class_name}.{class_name}", github_parent_path=github_parent_path |
| 296 | ) |
| 297 | |
| 298 | |
| 299 | @dataclasses.dataclass(frozen=True) |
no test coverage detected