Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 681afb1

Browse filesBrowse files
committed
refactor: Sort objects without line numbers last instead of first
1 parent 148f245 commit 681afb1
Copy full SHA for 681afb1

File tree

1 file changed

+7
-8
lines changed
Filter options

1 file changed

+7
-8
lines changed

‎src/mkdocstrings_handlers/python/_internal/rendering.py

Copy file name to clipboardExpand all lines: src/mkdocstrings_handlers/python/_internal/rendering.py
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,17 @@
4343
_logger = get_logger(__name__)
4444

4545

46-
def _sort_key_alphabetical(item: CollectorItem) -> Any:
47-
# chr(sys.maxunicode) is a string that contains the final unicode
48-
# character, so if 'name' isn't found on the object, the item will go to
49-
# the end of the list.
46+
def _sort_key_alphabetical(item: CollectorItem) -> str:
47+
# `chr(sys.maxunicode)` is a string that contains the final unicode character,
48+
# so if `name` isn't found on the object, the item will go to the end of the list.
5049
return item.name or chr(sys.maxunicode)
5150

5251

53-
def _sort_key_source(item: CollectorItem) -> Any:
54-
# if 'lineno' is none, the item will go to the start of the list.
52+
def _sort_key_source(item: CollectorItem) -> float:
53+
# If `lineno` is none, the item will go to the end of the list.
5554
if item.is_alias:
56-
return item.alias_lineno if item.alias_lineno is not None else -1
57-
return item.lineno if item.lineno is not None else -1
55+
return item.alias_lineno if item.alias_lineno is not None else float("inf")
56+
return item.lineno if item.lineno is not None else float("inf")
5857

5958

6059
Order = Literal["alphabetical", "source"]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.