(cls, data: Mapping[str, Any], *, path: str)
| 147 | |
| 148 | @classmethod |
| 149 | def from_dict(cls, data: Mapping[str, Any], *, path: str) -> "RegexSplitConfig": |
| 150 | mapping = require_mapping(data, path) |
| 151 | pattern = require_str(mapping, "pattern", path, allow_empty=False) |
| 152 | |
| 153 | group_value = mapping.get("group") |
| 154 | group_normalized: str | int | None = None |
| 155 | if group_value is not None: |
| 156 | if isinstance(group_value, int): |
| 157 | group_normalized = group_value |
| 158 | elif isinstance(group_value, str): |
| 159 | if group_value.isdigit(): |
| 160 | group_normalized = int(group_value) |
| 161 | else: |
| 162 | group_normalized = group_value |
| 163 | else: |
| 164 | raise ConfigError("group must be str or int", extend_path(path, "group")) |
| 165 | |
| 166 | case_sensitive = optional_bool(mapping, "case_sensitive", path, default=True) |
| 167 | multiline = optional_bool(mapping, "multiline", path, default=False) |
| 168 | dotall = optional_bool(mapping, "dotall", path, default=False) |
| 169 | on_no_match = optional_str(mapping, "on_no_match", path) or "pass" |
| 170 | |
| 171 | if on_no_match not in {"pass", "empty"}: |
| 172 | raise ConfigError("on_no_match must be 'pass' or 'empty'", extend_path(path, "on_no_match")) |
| 173 | |
| 174 | return cls( |
| 175 | pattern=pattern, |
| 176 | group=group_normalized, |
| 177 | case_sensitive=True if case_sensitive is None else bool(case_sensitive), |
| 178 | multiline=bool(multiline) if multiline is not None else False, |
| 179 | dotall=bool(dotall) if dotall is not None else False, |
| 180 | on_no_match=on_no_match, |
| 181 | path=path, |
| 182 | ) |
| 183 | |
| 184 | def display_label(self) -> str: |
| 185 | return f"regex({self.pattern})" |
nothing calls this directly
no test coverage detected