Skip to content

Commit

Permalink
deprecate isidentifier utility
Browse files Browse the repository at this point in the history
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
  • Loading branch information
minrk committed Nov 28, 2024
1 parent 9522ad6 commit a5dd56d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions traitlets/traitlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())


Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit a5dd56d

Please sign in to comment.