diff --git a/param/__init__.py b/param/__init__.py index 227316c82..afe73ccd4 100644 --- a/param/__init__.py +++ b/param/__init__.py @@ -2324,28 +2324,28 @@ class Path(Parameter): is None). """ - __slots__ = ['search_paths', 'notfound_ok'] + __slots__ = ['search_paths', 'check_exists'] _slot_defaults = _dict_update( - Parameter._slot_defaults, notfound_ok=False, + Parameter._slot_defaults, check_exists=True, ) @typing.overload def __init__( self, - default=None, *, search_paths=None, notfound_ok=False, + default=None, *, search_paths=None, check_exists=True, allow_None=False, doc=None, label=None, precedence=None, instantiate=False, constant=False, readonly=False, pickle_default_value=True, per_instance=True ): ... @_deprecate_positional_args - def __init__(self, default=Undefined, *, search_paths=Undefined, notfound_ok=Undefined, **params): + def __init__(self, default=Undefined, *, search_paths=Undefined, check_exists=Undefined, **params): if search_paths is Undefined: search_paths = [] self.search_paths = search_paths - self.notfound_ok = notfound_ok + self.check_exists = check_exists super().__init__(default,**params) self._validate(self.default) @@ -2360,7 +2360,7 @@ def _validate(self, val): try: self._resolve(val) except OSError as e: - if not self.notfound_ok: + if self.check_exists: raise OSError(e.args[0]) from None def __get__(self, obj, objtype): @@ -2374,7 +2374,7 @@ def __get__(self, obj, objtype): try: path = self._resolve(raw_path) except OSError: - if not self.notfound_ok: + if self.check_exists: raise else: path = raw_path diff --git a/tests/testpathparam.py b/tests/testpathparam.py index e69709ab2..2e1099c81 100644 --- a/tests/testpathparam.py +++ b/tests/testpathparam.py @@ -29,7 +29,7 @@ class P(param.Parameterized): a = param.Path() b = param.Path(self.fb) c = param.Path('a.txt', search_paths=[tmpdir1]) - d = param.Path(notfound_ok=True) + d = param.Path(check_exists=False) self.P = P @@ -40,7 +40,7 @@ def _check_defaults(self, p): assert p.default is None assert p.allow_None is True assert p.search_paths == [] - assert p.notfound_ok is False + assert p.check_exists is True def test_defaults_class(self): class P(param.Parameterized): @@ -145,7 +145,7 @@ def test_set_notfound_class_raises_error(self): self.P.a = 'non/existing/file' def test_notfoundok_unbound_no_error(self): - p = param.Path('non/existing/file', notfound_ok=True) + p = param.Path('non/existing/file', check_exists=False) assert p.default == 'non/existing/file' def test_notfoundok_class_no_error(self): @@ -181,7 +181,7 @@ class P(param.Parameterized): a = param.Filename() b = param.Filename(self.fb) c = param.Filename('a.txt', search_paths=[tmpdir1]) - d = param.Filename(notfound_ok=True) + d = param.Filename(check_exists=False) self.P = P @@ -192,7 +192,7 @@ def _check_defaults(self, p): assert p.default is None assert p.allow_None is True assert p.search_paths == [] - assert p.notfound_ok is False + assert p.check_exists is True def test_defaults_class(self): class P(param.Parameterized): @@ -268,7 +268,7 @@ def test_set_notfound_raises_error(self): p.a = 'non/existing/file' def test_notfoundok_unbound_no_error(self): - p = param.Filename('non/existing/file', notfound_ok=True) + p = param.Filename('non/existing/file', check_exists=False) assert p.default == 'non/existing/file' def test_notfoundok_class_no_error(self): @@ -301,7 +301,7 @@ class P(param.Parameterized): a = param.Foldername() b = param.Foldername(tmpdir1) c = param.Foldername('da', search_paths=[tmpdir1]) - d = param.Foldername(notfound_ok=True) + d = param.Foldername(check_exists=False) self.P = P @@ -312,7 +312,7 @@ def _check_defaults(self, p): assert p.default is None assert p.allow_None is True assert p.search_paths == [] - assert p.notfound_ok is False + assert p.check_exists is True def test_defaults_class(self): class P(param.Parameterized): @@ -389,7 +389,7 @@ def test_set_notfound_class_raises_error(self): self.P.a = 'non/existing/folder' def test_notfoundok_unbound_no_error(self): - p = param.Foldername('non/existing/folder', notfound_ok=True) + p = param.Foldername('non/existing/folder', check_exists=False) assert p.default == 'non/existing/folder' def test_notfoundok_class_no_error(self):