let it go

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 intelligently handles commas within regex patterns by only
118 splitting on commas that are not within parentheses, brackets, or quotes.
119 For example: '(foo{1,3}),bar' will be treated as a single pattern,
120 while 'foo,bar' will be treated as two patterns.
121 """
122 if not value:
123 return []
124
116125 patterns: list[Pattern[str]] = []
117 for pattern in _csv_transformer(value):
118 patterns.append(_regex_transformer(pattern))
126
127 # Split on commas that are not within parentheses, brackets, or quotes
128 parts = []
129 current_part = ""
130 paren_count = 0
131 bracket_count = 0
132 in_single_quote = False
133 in_double_quote = False
134 i = 0
135
136 while i < len(value):
137 char = value[i]
138
139 # Handle escape sequences
140 if char == '\\' and i + 1 < len(value):
141 current_part += char + value[i + 1]
142 i += 2
143 continue
144
145 # Track quote states
146 if char == "'" and not in_double_quote:
147 in_single_quote = not in_single_quote
148 elif char == '"' and not in_single_quote:
149 in_double_quote = not in_double_quote
150
151 # Track parentheses and brackets (only when not in quotes)
152 if not in_single_quote and not in_double_quote:
153 if char == '(':
154 paren_count += 1
155 elif char == ')':
156 paren_count -= 1
157 elif char == '[':
158 bracket_count += 1
159 elif char == ']':
160 bracket_count -= 1
161 elif char == ',' and paren_count == 0 and bracket_count == 0:
162 # This is a separator comma
163 parts.append(current_part.strip())
164 current_part = ""
165 i += 1
166 continue
167
168 current_part += char
169 i += 1
170
171 # Add the last part
172 if current_part.strip():
173 parts.append(current_part.strip())
174
175 # Compile each part as a regex pattern
176 for part in parts:
177 if part: # Skip empty patterns
178 patterns.append(_regex_transformer(part))
179
119180 return patterns
120181
121182
Test NameStatus
tests/config/test_config.py::test_csv_regex_error
Fail
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,
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_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.