| 53 | 53 | return pylint_utils._check_csv(value) |
| 54 | 54 | |
| 55 | 55 | |
| 56 | def _csv_transformer_escape(value: str) -> Sequence[str]: | |
| 57 | """Transforms a comma separated string with escaped comma support. | |
| 58 | ||
| 59 | Commas can be escaped with backslashes to include them in patterns. | |
| 60 | For example: (foo{1\\,3}),bar will be split into [(foo{1,3}), bar]. | |
| 61 | """ | |
| 62 | return pylint_utils._check_csv(value, escape=True) | |
| 63 | ||
| 64 | ||
| 56 | 65 | YES_VALUES = {"y", "yes", "true"} |
| 57 | 66 | NO_VALUES = {"n", "no", "false"} |
| 58 | 67 | |
| 112 | 121 | |
| 113 | 122 | |
| 114 | 123 | def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 115 | """Transforms a comma separated list of regular expressions.""" | |
| 124 | """Transforms a comma separated list of regular expressions. | |
| 125 | ||
| 126 | Commas in regular expressions can be escaped with backslashes. | |
| 127 | For example: (foo{1\\,3}) will be treated as a single pattern. | |
| 128 | """ | |
| 116 | 129 | patterns: list[Pattern[str]] = [] |
| 117 | for pattern in _csv_transformer(value): | |
| 118 | patterns.append(_regex_transformer(pattern)) | |
| 130 | for pattern in _csv_transformer_escape(value): | |
| 131 | # Unescape escaped commas before regex compilation | |
| 132 | unescaped_pattern = pattern.replace(r'\,', ',') | |
| 133 | patterns.append(_regex_transformer(unescaped_pattern)) | |
| 119 | 134 | return patterns |
| 120 | 135 | |
| 121 | 136 |
| 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.