A casting compiled regular expression trait. Accepts both strings and compiled regular expressions. The resulting attribute will be a compiled regular expression.
| 4194 | |
| 4195 | |
| 4196 | class 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 | |
| 4211 | class UseEnum(TraitType[t.Any, t.Any]): |
no outgoing calls
no test coverage detected
searching dependent graphs…