diff --git a/docs/changelog/2822.bugfix.rst b/docs/changelog/2822.bugfix.rst new file mode 100644 index 000000000..3c0dc9d8e --- /dev/null +++ b/docs/changelog/2822.bugfix.rst @@ -0,0 +1 @@ +Require space after colon before factor filter expansion, unless it is the last character of the line - by :user:`pdecat`. diff --git a/src/tox/config/loader/ini/factor.py b/src/tox/config/loader/ini/factor.py index e13b5ec95..c429efb1d 100644 --- a/src/tox/config/loader/ini/factor.py +++ b/src/tox/config/loader/ini/factor.py @@ -50,7 +50,7 @@ def expand_factors(value: str) -> Iterator[tuple[list[list[tuple[str, bool]]] | for line in value.split("\n"): factors: list[list[tuple[str, bool]]] | None = None marker_at, content = line.find(":"), line - if marker_at != -1: + if marker_at != -1 and (len(line) == marker_at + 1 or line[marker_at + 1] == " "): try: factors = list(find_factor_groups(line[:marker_at].strip())) except ValueError: diff --git a/tests/config/loader/ini/test_factor.py b/tests/config/loader/ini/test_factor.py index 00aa83c94..cec786b3f 100644 --- a/tests/config/loader/ini/test_factor.py +++ b/tests/config/loader/ini/test_factor.py @@ -30,6 +30,7 @@ def complex_example() -> str: py, d: space extra: extra more-default + no:space """, ) @@ -73,6 +74,7 @@ def test_factor_env_filter(env: str, complex_example: str) -> None: assert "default" in result assert "lines" in result assert "more-default" in result + assert "no:space" in result if "py" in env: assert "py only" in result assert "not py" not in result