sourdough

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 commas within regex patterns by using a more sophisticated
118 parsing approach that distinguishes between separator commas and commas that
119 are part of the regex pattern itself.
120 """
116121 patterns: list[Pattern[str]] = []
117 for pattern in _csv_transformer(value):
122 if not value.strip():
123 return patterns
124
125 # Parse comma-separated patterns while respecting commas within regex patterns
126 # We use a simple state machine to track whether we're inside brackets, braces, or parentheses
127 current_pattern = ""
128 bracket_depth = 0 # For []
129 brace_depth = 0 # For {}
130 paren_depth = 0 # For ()
131 in_char_class = False # For [] character classes
132
133 for char in value:
134 if char == '[' and not in_char_class:
135 bracket_depth += 1
136 in_char_class = True
137 elif char == ']' and in_char_class:
138 bracket_depth -= 1
139 in_char_class = False
140 elif char == '{' and not in_char_class:
141 brace_depth += 1
142 elif char == '}' and not in_char_class:
143 brace_depth -= 1
144 elif char == '(' and not in_char_class:
145 paren_depth += 1
146 elif char == ')' and not in_char_class:
147 paren_depth -= 1
148
149 # If we encounter a comma and we're not inside any regex constructs,
150 # treat it as a separator
151 if char == ',' and bracket_depth == 0 and brace_depth == 0 and paren_depth == 0 and not in_char_class:
152 pattern = current_pattern.strip()
153 if pattern:
154 patterns.append(_regex_transformer(pattern))
155 current_pattern = ""
156 else:
157 current_pattern += char
158
159 # Add the last pattern
160 pattern = current_pattern.strip()
161 if pattern:
118162 patterns.append(_regex_transformer(pattern))
163
119164 return patterns
120165
121166
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.