File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 4
4
import os
5
5
import sys
6
6
import pathlib
7
+ import warnings
7
8
from contextlib import suppress
8
9
from typing import Union
9
10
@@ -107,3 +108,19 @@ def wrap_spec(package):
107
108
else :
108
109
# PathLike is only subscriptable at runtime in 3.9+
109
110
StrPath = Union [str , "os.PathLike[str]" ]
111
+
112
+
113
+ def ensure_traversable (path ):
114
+ """
115
+ Convert deprecated string arguments to traversables (pathlib.Path).
116
+ """
117
+ if not isinstance (path , str ):
118
+ return path
119
+
120
+ warnings .warn (
121
+ "String arguments are deprecated. Pass a Traversable instead." ,
122
+ DeprecationWarning ,
123
+ stacklevel = 3 ,
124
+ )
125
+
126
+ return pathlib .Path (path )
Original file line number Diff line number Diff line change 6
6
from . import abc
7
7
8
8
from ._itertools import only
9
- from ._compat import ZipPath
9
+ from ._compat import ZipPath , ensure_traversable
10
10
11
11
12
12
def remove_duplicates (items ):
@@ -62,7 +62,7 @@ class MultiplexedPath(abc.Traversable):
62
62
"""
63
63
64
64
def __init__ (self , * paths ):
65
- self ._paths = list (map (pathlib . Path , remove_duplicates (paths )))
65
+ self ._paths = list (map (ensure_traversable , remove_duplicates (paths )))
66
66
if not self ._paths :
67
67
message = 'MultiplexedPath must contain at least one path'
68
68
raise FileNotFoundError (message )
You can’t perform that action at this time.
0 commit comments