Skip to content

Commit 681afb1

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

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/mkdocstrings_handlers/python/_internal/rendering.py

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy