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 101a6dc

Browse filesBrowse 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
Copy full SHA for 101a6dc

File tree

2 files changed

+8
-9
lines changed
Filter options

2 files changed

+8
-9
lines changed

‎src/mkdocstrings_handlers/python/handler.py

Copy file name to clipboardExpand all lines: src/mkdocstrings_handlers/python/handler.py
+3-5Lines 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

Copy file name to clipboardExpand all lines: tests/test_handler.py
+5-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.