corpus

Finished
102102 return version
103103
104104
105def _split_csv_with_quotes(value: str) -> list[str]:
106 """Split a comma-separated string, respecting quoted fields.
107
108 Supports both single and double quotes. Quotes are removed from the result.
109 Whitespace is stripped from unquoted fields.
110
111 Examples:
112 _split_csv_with_quotes('a,b,c') -> ['a', 'b', 'c']
113 _split_csv_with_quotes('"a,b",c') -> ['a,b', 'c']
114 _split_csv_with_quotes('"foo{1,3}",bar') -> ['foo{1,3}', 'bar']
115 """
116 if not value:
117 return []
118
119 result = []
120 current = ""
121 in_quotes = False
122 quote_char = None
123 i = 0
124
125 while i < len(value):
126 char = value[i]
127
128 if not in_quotes:
129 if char == "'" or char == '"':
130 in_quotes = True
131 quote_char = char
132 elif char == ",":
133 result.append(current.strip())
134 current = ""
135 else:
136 current += char
137 else:
138 # We are inside quotes
139 if char == quote_char:
140 # Check if this is an escaped quote
141 if i + 1 < len(value) and value[i + 1] == quote_char:
142 # This is an escaped quote, add one quote character
143 current += char
144 i += 1 # Skip the next quote
145 else:
146 # This is the closing quote
147 in_quotes = False
148 quote_char = None
149 else:
150 current += char
151 i += 1
152
153 # Add the last field
154 if current or value.endswith(","):
155 result.append(current.strip() if not in_quotes else current)
156
157 return result
158
105159def _regex_transformer(value: str) -> Pattern[str]:
106160 """Return `re.compile(value)`."""
107161 try:
112166
113167
114168def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
115 """Transforms a comma separated list of regular expressions."""
169 """Transforms a comma separated list of regular expressions.
170
171 Supports quoted patterns that contain commas, e.g. "(foo{1,3})".
172 """
116173 patterns: list[Pattern[str]] = []
117 for pattern in _csv_transformer(value):
174 for pattern in _split_csv_with_quotes(value):
118175 patterns.append(_regex_transformer(pattern))
119176 return patterns
120177
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.