future

Finished
112112
113113
114114def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
115 """Transforms a comma separated list of regular expressions."""
115 """Transforms a comma separated list of regular expressions.
116
117 This function handles both:
118 1. Multiple regex patterns separated by commas (e.g., "pattern1,pattern2")
119 2. Single regex patterns containing commas (e.g., "(foo{1,3})")
120
121 The parser intelligently distinguishes between commas that separate patterns
122 and commas that are part of regex syntax (like in quantifiers {1,3}).
123 """
116124 patterns: list[Pattern[str]] = []
117 for pattern in _csv_transformer(value):
125
126 # Handle empty string
127 if not value.strip():
128 return patterns
129
130 # Split on commas, but be smart about regex syntax
131 current_pattern = ""
132 brace_depth = 0
133 bracket_depth = 0
134 paren_depth = 0
135 in_char_class = False
136 i = 0
137
138 while i < len(value):
139 char = value[i]
140
141 # Track nesting levels to avoid splitting inside regex constructs
142 if char == '[' and not in_char_class:
143 in_char_class = True
144 bracket_depth += 1
145 elif char == ']' and in_char_class:
146 in_char_class = False
147 bracket_depth -= 1
148 elif char == '{' and not in_char_class:
149 brace_depth += 1
150 elif char == '}' and not in_char_class:
151 brace_depth -= 1
152 elif char == '(' and not in_char_class:
153 paren_depth += 1
154 elif char == ')' and not in_char_class:
155 paren_depth -= 1
156
157 # If we find a comma at the top level (not inside any regex construct),
158 # it's a separator between patterns
159 if char == ',' and brace_depth == 0 and bracket_depth == 0 and paren_depth == 0 and not in_char_class:
160 pattern = current_pattern.strip()
161 if pattern: # Only add non-empty patterns
162 patterns.append(_regex_transformer(pattern))
163 current_pattern = ""
164 else:
165 current_pattern += char
166
167 i += 1
168
169 # Add the last pattern
170 pattern = current_pattern.strip()
171 if pattern:
118172 patterns.append(_regex_transformer(pattern))
173
119174 return patterns
120175
121176
Test NameStatus
tests/config/test_config.py::test_csv_regex_error
Fail
tests/config/test_config.py::test_can_read_toml_env_variable
Pass
tests/config/test_config.py::test_unknown_message_id
Pass
tests/config/test_config.py::test_unknown_option_name
Pass
tests/config/test_config.py::test_unknown_short_option_name
Pass
tests/config/test_config.py::test_unknown_confidence
Pass
tests/config/test_config.py::test_empty_confidence
Pass
tests/config/test_config.py::test_unknown_yes_no
Pass
tests/config/test_config.py::test_unknown_py_version
Pass
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo-expected0]
Pass
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,bar-expected1]
Pass
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,
Pass
tests/config/test_config.py::test_regex_error
Pass
tests/config/test_config.py::test_short_verbose
Pass
tests/config/test_config.py::test_argument_separator
Pass
tests/config/test_config.py::test_clear_cache_post_run
Pass
tests/config/test_config.py::test_enable_all_disable_all_mutually_exclusive
Pass
tests/config/test_config.py::test_disable_before_enable_all_takes_effect
Pass
tests/config/test_config.py::test_enable_before_disable_all_takes_effect
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.