| 111 | 111 | raise argparse.ArgumentTypeError(msg) from e |
| 112 | 112 | |
| 113 | 113 | |
| 114 | def _split_regex_csv(value: str) -> list[str]: | |
| 115 | """Split a comma-separated list of regex patterns, respecting quoted patterns. | |
| 116 | ||
| 117 | This function handles quoted regex patterns to prevent commas within | |
| 118 | regex quantifiers (like {1,3}) from being treated as separators. | |
| 119 | """ | |
| 120 | if not value: | |
| 121 | return [] | |
| 122 | ||
| 123 | # Handle quoted patterns | |
| 124 | patterns = [] | |
| 125 | current_pattern = "" | |
| 126 | in_single_quote = False | |
| 127 | in_double_quote = False | |
| 128 | i = 0 | |
| 129 | ||
| 130 | while i < len(value): | |
| 131 | char = value[i] | |
| 132 | ||
| 133 | if char == "'" and not in_double_quote: | |
| 134 | in_single_quote = not in_single_quote | |
| 135 | current_pattern += char | |
| 136 | elif char == '"' and not in_single_quote: | |
| 137 | in_double_quote = not in_double_quote | |
| 138 | current_pattern += char | |
| 139 | elif char == ',' and not in_single_quote and not in_double_quote: | |
| 140 | # End of current pattern | |
| 141 | patterns.append(current_pattern.strip()) | |
| 142 | current_pattern = "" | |
| 143 | else: | |
| 144 | current_pattern += char | |
| 145 | ||
| 146 | i += 1 | |
| 147 | ||
| 148 | # Add the last pattern | |
| 149 | if current_pattern: | |
| 150 | patterns.append(current_pattern.strip()) | |
| 151 | ||
| 152 | # Unquote each pattern | |
| 153 | result = [] | |
| 154 | for pattern in patterns: | |
| 155 | unquoted = pylint_utils._unquote(pattern) | |
| 156 | if unquoted: # Skip empty patterns | |
| 157 | result.append(unquoted) | |
| 158 | ||
| 159 | return result | |
| 160 | ||
| 161 | ||
| 114 | 162 | def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 115 | 163 | """Transforms a comma separated list of regular expressions.""" |
| 116 | 164 | patterns: list[Pattern[str]] = [] |
| 117 | for pattern in _csv_transformer(value): | |
| 165 | for pattern in _split_regex_csv(value): | |
| 118 | 166 | patterns.append(_regex_transformer(pattern)) |
| 119 | 167 | return patterns |
| 120 | 168 |
| Test Name | Status |
|---|---|
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.