Skip to content

Commit f2f70bb

Browse files
committed
format
1 parent 577726e commit f2f70bb

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

pandas/io/common.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,17 @@ def dedup_names(
12911291

12921292

12931293
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+
"""
12941305
# Treat Windows drive letters like C:\ as local file paths
12951306
if is_platform_windows() and re.match(r"^[a-zA-Z]:[\\/]", path):
12961307
return "file"
@@ -1325,6 +1336,17 @@ def _match_file(
13251336

13261337

13271338
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+
"""
13281350
parsed = parse_url(path_str)
13291351

13301352
if is_platform_windows():
@@ -1345,7 +1367,9 @@ def iterdir(
13451367
glob: str | None = None,
13461368
storage_options: StorageOptions | None = None,
13471369
) -> 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.
13491373
13501374
Supports:
13511375
- Local paths (str, os.PathLike)
@@ -1371,18 +1395,18 @@ def iterdir(
13711395
13721396
Raises
13731397
------
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.
13761404
ImportError
13771405
If fsspec is required but not installed.
13781406
"""
13791407

13801408
# 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):
13861410
return path
13871411

13881412
if not isinstance(path, (str, os.PathLike)):

0 commit comments

Comments
 (0)