MCPcopy Create free account
hub / github.com/ipython/traitlets / CRegExp

Class CRegExp

traitlets/traitlets.py:4196–4208  ·  view source on GitHub ↗

A casting compiled regular expression trait. Accepts both strings and compiled regular expressions. The resulting attribute will be a compiled regular expression.

Source from the content-addressed store, hash-verified

4194
4195
4196class CRegExp(TraitType["re.Pattern[t.Any]", t.Union["re.Pattern[t.Any]", str]]):
4197 """A casting compiled regular expression trait.
4198
4199 Accepts both strings and compiled regular expressions. The resulting
4200 attribute will be a compiled regular expression."""
4201
4202 info_text = "a regular expression"
4203
4204 def validate(self, obj: t.Any, value: t.Any) -> re.Pattern[t.Any] | None:
4205 try:
4206 return re.compile(value)
4207 except Exception:
4208 self.error(obj, value)
4209
4210
4211class UseEnum(TraitType[t.Any, t.Any]):

Callers 1

CRegExpTraitClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…