Get GitHub source link for an object.
(obj: griffe_t.Object)
| 124 | |
| 125 | |
| 126 | def get_source_link(obj: griffe_t.Object) -> str | None: |
| 127 | """Get GitHub source link for an object.""" |
| 128 | if not hasattr(obj, "filepath") or not obj.filepath: |
| 129 | return None |
| 130 | try: |
| 131 | raw_filepath = obj.filepath |
| 132 | # Handle case where filepath might be a list (griffe edge case) |
| 133 | if isinstance(raw_filepath, list): |
| 134 | resolved_path: Path | None = raw_filepath[0] if raw_filepath else None |
| 135 | else: |
| 136 | resolved_path = raw_filepath |
| 137 | if not resolved_path: |
| 138 | return None |
| 139 | rel_path = resolved_path.relative_to(PACKAGE_DIR) |
| 140 | except ValueError: |
| 141 | return None |
| 142 | line = obj.lineno if hasattr(obj, "lineno") and obj.lineno else 1 |
| 143 | return f"{GITHUB_BASE}/{rel_path}#L{line}" |
| 144 | |
| 145 | |
| 146 | def format_type(annotation: Any) -> str: |
no outgoing calls
no test coverage detected
searching dependent graphs…