summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Decat <pdecat@gmail.com>2023-01-05 01:10:18 +0100
committerGitHub <noreply@github.com>2023-01-04 16:10:18 -0800
commit497c17c5c043801a9d61f63472feed24f0af7250 (patch)
tree8436117d5682d3fa5a0097c5205c54403d811040
parent36fe263bd14a6379ec570817ade6677487f08a23 (diff)
downloadtox-git-497c17c5c043801a9d61f63472feed24f0af7250.tar.gz
Require space after colon before factor expansion (#2822)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Resolves https://github.com/tox-dev/tox/issues/2821
-rw-r--r--docs/changelog/2822.bugfix.rst1
-rw-r--r--src/tox/config/loader/ini/factor.py2
-rw-r--r--tests/config/loader/ini/test_factor.py2
3 files changed, 4 insertions, 1 deletions
diff --git a/docs/changelog/2822.bugfix.rst b/docs/changelog/2822.bugfix.rst
new file mode 100644
index 00000000..3c0dc9d8
--- /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 e13b5ec9..c429efb1 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 00aa83c9..cec786b3 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