Skip to content

Commit 1805ad9

Browse files
authored
deprecate empty isidentifier utility (#915)
1 parent 6d4dbac commit 1805ad9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

traitlets/traitlets.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ class TraitError(Exception):
170170

171171

172172
def isidentifier(s: t.Any) -> bool:
173+
warn(
174+
"traitlets.traitlets.isidentifier(s) is deprecated since traitlets 5.14.4 Use `s.isidentifier()`.",
175+
DeprecationWarning,
176+
stacklevel=2,
177+
)
173178
return t.cast(bool, s.isidentifier())
174179

175180

@@ -3025,7 +3030,7 @@ class ObjectName(TraitType[str, str]):
30253030
def validate(self, obj: t.Any, value: t.Any) -> str:
30263031
value = self.coerce_str(obj, value)
30273032

3028-
if isinstance(value, str) and isidentifier(value):
3033+
if isinstance(value, str) and value.isidentifier():
30293034
return value
30303035
self.error(obj, value)
30313036

@@ -3041,7 +3046,7 @@ class DottedObjectName(ObjectName):
30413046
def validate(self, obj: t.Any, value: t.Any) -> str:
30423047
value = self.coerce_str(obj, value)
30433048

3044-
if isinstance(value, str) and all(isidentifier(a) for a in value.split(".")):
3049+
if isinstance(value, str) and all(a.isidentifier() for a in value.split(".")):
30453050
return value
30463051
self.error(obj, value)
30473052

0 commit comments

Comments
 (0)