Skip to content

Commit

Permalink
Merge pull request #158 from Dobatymo/no-convert-path
Browse files Browse the repository at this point in the history
os_sorted: only convert input to str if necessary
  • Loading branch information
SethMMorton committed Jan 11, 2023
2 parents 837a387 + 8298971 commit 34078b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion natsort/natsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import platform
from functools import partial
from operator import itemgetter
from pathlib import PurePath
from typing import (
Any,
Callable,
Expand Down Expand Up @@ -669,7 +670,9 @@ def _split_apply(
) -> Iterator[str]:
if key is not None:
v = key(v)
return utils.path_splitter(str(v))
if not isinstance(v, (str, PurePath)):
v = str(v)
return utils.path_splitter(v)


# Choose the implementation based on the host OS
Expand Down

0 comments on commit 34078b7

Please sign in to comment.