From a5dd56da3c238d224fc2579b29289b05019dc0ea Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 28 Nov 2024 12:53:31 +0100 Subject: [PATCH] deprecate isidentifier utility now a no-op alias to s.isidentifier() after removal of Python 2 compat this is not exported or documented, so probably safe to remove, but better to be safe --- traitlets/traitlets.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/traitlets/traitlets.py b/traitlets/traitlets.py index ecd0d7cc..41e5c208 100644 --- a/traitlets/traitlets.py +++ b/traitlets/traitlets.py @@ -170,6 +170,11 @@ class TraitError(Exception): def isidentifier(s: t.Any) -> bool: + warn( + "traitlets.traitlets.isidentifier(s) is deprecated since traitlets 5.14.4 Use `s.isidentifier()`.", + DeprecationWarning, + stacklevel=2, + ) return t.cast(bool, s.isidentifier()) @@ -3025,7 +3030,7 @@ class ObjectName(TraitType[str, str]): def validate(self, obj: t.Any, value: t.Any) -> str: value = self.coerce_str(obj, value) - if isinstance(value, str) and isidentifier(value): + if isinstance(value, str) and value.isidentifier(): return value self.error(obj, value) @@ -3041,7 +3046,7 @@ class DottedObjectName(ObjectName): def validate(self, obj: t.Any, value: t.Any) -> str: value = self.coerce_str(obj, value) - if isinstance(value, str) and all(isidentifier(a) for a in value.split(".")): + if isinstance(value, str) and all(a.isidentifier() for a in value.split(".")): return value self.error(obj, value)