Skip to content

Commit 101a6dc

Browse files
committed
fix: Fix normalization of extension paths on the annoying operating system and Python 3.13
Python 3.13 changed `os.path.isabs`: > On Windows, `isabs()` no longer considers paths starting with exactly one slash (`\` or `/`) to be absolute. See https://docs.python.org/3/whatsnew/3.13.html#os-path.
1 parent 6c5b5c3 commit 101a6dc

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/mkdocstrings_handlers/python/handler.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,9 @@ def normalize_extension_paths(self, extensions: Sequence) -> Sequence:
469469
pth = str(ext)
470470
options = None
471471

472-
if pth.endswith(".py") or ".py:" in pth or "/" in pth or "\\" in pth: # noqa: SIM102
473-
# This is a sytem path. Normalize it.
474-
if not os.path.isabs(pth):
475-
# Make path absolute relative to config file path.
476-
pth = os.path.normpath(os.path.join(base_path, pth))
472+
if pth.endswith(".py") or ".py:" in pth or "/" in pth or "\\" in pth:
473+
# This is a system path. Normalize it, make it absolute relative to config file path.
474+
pth = os.path.abspath(os.path.join(base_path, pth))
477475

478476
if options is not None:
479477
normalized.append({pth: options})

tests/test_handler.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ def test_expand_globs_without_changing_directory() -> None:
119119
(True, {"extension.py:SomeExtension": {"option": "value"}}),
120120
(True, {"path/to/extension.py": {"option": "value"}}),
121121
(True, {"path/to/extension.py:SomeExtension": {"option": "value"}}),
122-
(False, "/absolute/path/to/extension.py"),
123-
(False, "/absolute/path/to/extension.py:SomeExtension"),
124-
(False, {"/absolute/path/to/extension.py": {"option": "value"}}),
125-
(False, {"/absolute/path/to/extension.py:SomeExtension": {"option": "value"}}),
122+
# True because OS path normalization.
123+
(True, "/absolute/path/to/extension.py"),
124+
(True, "/absolute/path/to/extension.py:SomeExtension"),
125+
(True, {"/absolute/path/to/extension.py": {"option": "value"}}),
126+
(True, {"/absolute/path/to/extension.py:SomeExtension": {"option": "value"}}),
126127
(False, "dot.notation.path.to.extension"),
127128
(False, "dot.notation.path.to.pyextension"),
128129
(False, {"dot.notation.path.to.extension": {"option": "value"}}),

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