summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBernát Gábor <gaborjbernat@gmail.com>2022-12-19 14:26:31 -0800
committerGitHub <noreply@github.com>2022-12-19 14:26:31 -0800
commit294159e7db8e17955009ccf4567f03a9796b46bc (patch)
treefc27d45a1a5925d2c760ceb53d41c5a55b3c1ca9 /src
parent55a7b66faeaef2686eaeebdebb02d433a0d49a6b (diff)
downloadtox-git-294159e7db8e17955009ccf4567f03a9796b46bc.tar.gz
Fix complex negative factor filters not working (#2757)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Resolves https://github.com/tox-dev/tox/issues/2747
Diffstat (limited to 'src')
-rw-r--r--src/tox/config/loader/ini/factor.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tox/config/loader/ini/factor.py b/src/tox/config/loader/ini/factor.py
index bc121a65..e13b5ec9 100644
--- a/src/tox/config/loader/ini/factor.py
+++ b/src/tox/config/loader/ini/factor.py
@@ -67,6 +67,9 @@ def find_factor_groups(value: str) -> Iterator[list[tuple[str, bool]]]:
yield result
+_FACTOR_RE = re.compile(r"!?[\w._][\w._-]*")
+
+
def expand_env_with_negation(value: str) -> Iterator[str]:
"""transform '{py,!pi}-{a,b},c' to ['py-a', 'py-b', '!pi-a', '!pi-b', 'c']"""
for key, group in groupby(re.split(r"((?:{[^}]+})+)|,", value), key=bool):
@@ -76,7 +79,7 @@ def expand_env_with_negation(value: str) -> Iterator[str]:
parts = [[i.strip() for i in elem.split(",")] for elem in elements]
for variant in product(*parts):
variant_str = "".join(variant)
- if not re.fullmatch(r"!?[\w._][\w._-]*", variant_str):
+ if not all(_FACTOR_RE.fullmatch(i) for i in variant_str.split("-")):
raise ValueError(variant_str)
yield variant_str