From fd2749e3eeb4ca8e0bc118ec28022a921f411997 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sat, 10 Oct 2020 12:02:05 +0100 Subject: MAINT: Cleanup compatibility code for pathlib `Path` can now never be none, and `PurePath` is not used and not in `__all__`. --- numpy/compat/py3k.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'numpy/compat') diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py index 5e742bf6c..f36aaca17 100644 --- a/numpy/compat/py3k.py +++ b/numpy/compat/py3k.py @@ -18,7 +18,7 @@ __all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar', import sys import os -from pathlib import Path, PurePath +from pathlib import Path import io import abc @@ -78,11 +78,11 @@ def asunicode_nested(x): def is_pathlib_path(obj): """ - Check whether obj is a pathlib.Path object. + Check whether obj is a `pathlib.Path` object. - Prefer using `isinstance(obj, os_PathLike)` instead of this function. + Prefer using ``isinstance(obj, os.PathLike)`` instead of this function. """ - return Path is not None and isinstance(obj, Path) + return isinstance(obj, Path) # from Python 3.7 class contextlib_nullcontext: @@ -132,6 +132,5 @@ def npy_load_module(name, fn, info=None): return SourceFileLoader(name, fn).load_module() -# Backport os.fs_path, os.PathLike, and PurePath.__fspath__ os_fspath = os.fspath os_PathLike = os.PathLike -- cgit v1.2.1