Skip to content

Commit b681690

Browse files
committed
Remove SourceLocation TypedDict to use dict
1 parent d05a955 commit b681690

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

great_docs/core.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,10 @@
33
import shutil
44
from importlib import resources
55
from pathlib import Path
6-
from typing import TypedDict
76

87
import yaml
98

109

11-
class SourceLocation(TypedDict, total=False):
12-
"""Type for source location information."""
13-
14-
file: str
15-
start_line: int
16-
end_line: int
17-
github_url: str | None
18-
19-
2010
class GreatDocs:
2111
"""
2212
GreatDocs class for creating beautiful API documentation sites.
@@ -418,7 +408,7 @@ def _get_github_repo_info(self) -> tuple[str | None, str | None, str | None]:
418408

419409
return None, None, None
420410

421-
def _get_source_location(self, package_name: str, item_name: str) -> SourceLocation | None:
411+
def _get_source_location(self, package_name: str, item_name: str) -> dict | None:
422412
"""
423413
Get source file and line numbers for a class, method, or function.
424414
@@ -433,7 +423,7 @@ def _get_source_location(self, package_name: str, item_name: str) -> SourceLocat
433423
434424
Returns
435425
-------
436-
SourceLocation | None
426+
dict | None
437427
Dictionary with file path and line numbers, or None if not found.
438428
"""
439429
try:
@@ -469,19 +459,19 @@ def _get_source_location(self, package_name: str, item_name: str) -> SourceLocat
469459
# Get end line number
470460
end_lineno = getattr(obj, "endlineno", obj.lineno)
471461

472-
return SourceLocation(
473-
file=filepath,
474-
start_line=obj.lineno,
475-
end_line=end_lineno or obj.lineno,
476-
)
462+
return {
463+
"file": filepath,
464+
"start_line": obj.lineno,
465+
"end_line": end_lineno or obj.lineno,
466+
}
477467

478468
except ImportError:
479469
return None
480470
except Exception:
481471
return None
482472

483473
def _build_github_source_url(
484-
self, source_location: SourceLocation, branch: str | None = None
474+
self, source_location: dict, branch: str | None = None
485475
) -> str | None:
486476
"""
487477
Build a GitHub URL for viewing source code at specific line numbers.

0 commit comments

Comments
 (0)