Skip to content

Commit 4d3db76

Browse files
committed
Replace os.path.splitext with pathlib.Path for consistency
Use pathlib.Path.with_suffix('') instead of os.path.splitext()[0] for better consistency with modern Python practices. This removes the os import which was only used for this single operation.
1 parent 1fd4506 commit 4d3db76

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sphinx_exercise/directive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:licences: see LICENSE for details
99
"""
1010

11-
import os
11+
from pathlib import Path
1212
from typing import List
1313

1414
from docutils import nodes
@@ -42,7 +42,7 @@ def duplicate_labels(self, label):
4242

4343
if not label == "" and label in self.env.sphinx_exercise_registry.keys():
4444
docpath = self.env.doc2path(self.env.docname)
45-
path = os.path.splitext(docpath)[0]
45+
path = str(Path(docpath).with_suffix(""))
4646
other_path = self.env.doc2path(
4747
self.env.sphinx_exercise_registry[label]["docname"]
4848
)

0 commit comments

Comments
 (0)