Skip to content

Commit

Permalink
refactor: Return anchors as a tuple, not a set, to preserve order
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Aug 21, 2023
1 parent 20be8f8 commit 736a2b5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/mkdocstrings_handlers/python/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,17 @@ def update_env(self, md: Markdown, config: dict) -> None: # noqa: D102 (ignore
self.env.filters["get_template"] = rendering.do_get_template
self.env.tests["existing_template"] = lambda template_name: template_name in self.env.list_templates()

def get_anchors(self, data: CollectorItem) -> set[str]: # noqa: D102 (ignore missing docstring)
def get_anchors(self, data: CollectorItem) -> tuple[str, ...]: # noqa: D102 (ignore missing docstring)
anchors = [data.path]
try:
return {data.path, data.canonical_path, *data.aliases}
if data.canonical_path != data.path:
anchors.append(data.canonical_path)
for anchor in data.aliases:
if anchor not in anchors:
anchors.append(anchor)
except AliasResolutionError:
return {data.path}
return tuple(anchors)
return tuple(anchors)


def get_handler(
Expand Down

0 comments on commit 736a2b5

Please sign in to comment.