Skip to content

Commit

Permalink
deprecate empty isidentifier utility (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk authored Feb 4, 2025
1 parent 6d4dbac commit 1805ad9
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 1805ad9

Please sign in to comment.