Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate empty isidentifier utility #915

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading