@@ -1291,6 +1291,17 @@ def dedup_names(
1291
1291
1292
1292
1293
1293
def _infer_protocol (path : str ) -> str :
1294
+ """
1295
+ Infer the protocol of a given path string.
1296
+ Parameters
1297
+ ----------
1298
+ path : str
1299
+ The path string to infer the protocol from.
1300
+ Returns
1301
+ -------
1302
+ str
1303
+ The inferred protocol.
1304
+ """
1294
1305
# Treat Windows drive letters like C:\ as local file paths
1295
1306
if is_platform_windows () and re .match (r"^[a-zA-Z]:[\\/]" , path ):
1296
1307
return "file"
@@ -1325,6 +1336,17 @@ def _match_file(
1325
1336
1326
1337
1327
1338
def _resolve_local_path (path_str : str ) -> Path :
1339
+ """
1340
+ Resolve a local file path, handling Windows paths and file URLs.
1341
+ Parameters
1342
+ ----------
1343
+ path_str : str
1344
+ The path string to resolve.
1345
+ Returns
1346
+ -------
1347
+ Path
1348
+ A Path object representing the resolved local path.
1349
+ """
1328
1350
parsed = parse_url (path_str )
1329
1351
1330
1352
if is_platform_windows ():
@@ -1345,7 +1367,9 @@ def iterdir(
1345
1367
glob : str | None = None ,
1346
1368
storage_options : StorageOptions | None = None ,
1347
1369
) -> FilePath | list [FilePath ] | ReadCsvBuffer [bytes ] | ReadCsvBuffer [str ]:
1348
- """Yield file paths in a directory (no nesting allowed).
1370
+ """
1371
+ Yield file paths in a directory (no nesting allowed). File-like objects
1372
+ and string URLs are returned directly. Remote paths are handled via fsspec.
1349
1373
1350
1374
Supports:
1351
1375
- Local paths (str, os.PathLike)
@@ -1371,18 +1395,18 @@ def iterdir(
1371
1395
1372
1396
Raises
1373
1397
------
1374
- NotADirectoryError
1375
- If the given path is not a directory.
1398
+ TypeError
1399
+ If `path` is not a string, os.PathLike, or file-like object.
1400
+ FileNotFoundError
1401
+ If the specified path does not exist.
1402
+ ValueError
1403
+ If the specified path is neither a file nor a directory.
1376
1404
ImportError
1377
1405
If fsspec is required but not installed.
1378
1406
"""
1379
1407
1380
1408
# file-like objects and urls are returned directly
1381
- if (
1382
- hasattr (path , "read" )
1383
- or hasattr (path , "write" )
1384
- or (isinstance (path , str ) and is_url (path ))
1385
- ):
1409
+ if hasattr (path , "read" ) or hasattr (path , "write" ) or is_url (path ):
1386
1410
return path
1387
1411
1388
1412
if not isinstance (path , (str , os .PathLike )):
0 commit comments