Skip to content

Commit 497c17c

Browse files
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 #2821
1 parent 36fe263 commit 497c17c

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

docs/changelog/2822.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Require space after colon before factor filter expansion, unless it is the last character of the line - by :user:`pdecat`.

src/tox/config/loader/ini/factor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def expand_factors(value: str) -> Iterator[tuple[list[list[tuple[str, bool]]] |
5050
for line in value.split("\n"):
5151
factors: list[list[tuple[str, bool]]] | None = None
5252
marker_at, content = line.find(":"), line
53-
if marker_at != -1:
53+
if marker_at != -1 and (len(line) == marker_at + 1 or line[marker_at + 1] == " "):
5454
try:
5555
factors = list(find_factor_groups(line[:marker_at].strip()))
5656
except ValueError:

tests/config/loader/ini/test_factor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def complex_example() -> str:
3030
py, d: space
3131
extra: extra
3232
more-default
33+
no:space
3334
""",
3435
)
3536

@@ -73,6 +74,7 @@ def test_factor_env_filter(env: str, complex_example: str) -> None:
7374
assert "default" in result
7475
assert "lines" in result
7576
assert "more-default" in result
77+
assert "no:space" in result
7678
if "py" in env:
7779
assert "py only" in result
7880
assert "not py" not in result

0 commit comments

Comments
 (0)