mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2024-11-14 10:44:28 +00:00
exclude paths at the filesystem root
This commit is contained in:
parent
f376836e28
commit
d622b5914f
1 changed files with 5 additions and 1 deletions
|
@ -82,9 +82,13 @@ def _relativize_paths(
|
|||
|
||||
def _absolutize_paths(value: dict, skip: Iterable = tuple()) -> dict:
|
||||
def _a_path(v: Any) -> Any:
|
||||
if not isinstance(v, (str, Path)):
|
||||
return v
|
||||
try:
|
||||
path = Path(v)
|
||||
if not path.exists():
|
||||
# skip things that are pathlike but either don't exist
|
||||
# or that are at the filesystem root (eg like /data)
|
||||
if not path.exists() and path.parent != Path().root:
|
||||
return v
|
||||
return str(path.resolve())
|
||||
except (TypeError, ValueError):
|
||||
|
|
Loading…
Reference in a new issue