Skip to content

Commit

Permalink
Require space after colon before factor expansion (#2822)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Resolves #2821
  • Loading branch information
pdecat authored Jan 5, 2023
1 parent 36fe263 commit 497c17c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog/2822.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Require space after colon before factor filter expansion, unless it is the last character of the line - by :user:`pdecat`.
2 changes: 1 addition & 1 deletion src/tox/config/loader/ini/factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/config/loader/ini/test_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def complex_example() -> str:
py, d: space
extra: extra
more-default
no:space
""",
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 497c17c

Please sign in to comment.