Skip to content

Commit af4b558

Browse files
authored
Also accept tab after colon before factor filter expansion (#2823)
1 parent f07335d commit af4b558

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

docs/changelog/2823.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Also accept tab after colon before factor filter expansion - by :user:`pdecat`.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def explode_factor(group: list[tuple[str, bool]]) -> str:
4949
def expand_factors(value: str) -> Iterator[tuple[list[list[tuple[str, bool]]] | None, str]]:
5050
for line in value.split("\n"):
5151
factors: list[list[tuple[str, bool]]] | None = None
52-
marker_at, content = line.find(":"), line
53-
if marker_at != -1 and (len(line) == marker_at + 1 or line[marker_at + 1] == " "):
52+
marker_search = re.search(r":(\s|$)", line)
53+
marker_at, content = marker_search.start() if marker_search else -1, line
54+
if marker_at != -1:
5455
try:
5556
factors = list(find_factor_groups(line[:marker_at].strip()))
5657
except ValueError:

tests/config/loader/ini/test_factor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def complex_example() -> str:
3131
extra: extra
3232
more-default
3333
no:space
34+
trailingcolon:
35+
tab:\ttab
3436
""",
3537
)
3638

@@ -50,6 +52,8 @@ def test_factor_env_discover(complex_example: str) -> None:
5052
"c",
5153
"d",
5254
"extra",
55+
"trailingcolon",
56+
"tab",
5357
]
5458

5559

@@ -67,6 +71,8 @@ def test_factor_env_discover(complex_example: str) -> None:
6771
"pi-b-dev",
6872
"c",
6973
"extra",
74+
"trailingcolon",
75+
"tab",
7076
],
7177
)
7278
def test_factor_env_filter(env: str, complex_example: str) -> None:

0 commit comments

Comments
 (0)