Skip to content

Commit

Permalink
Also accept tab after colon before factor filter expansion (#2823)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdecat committed Jan 5, 2023
1 parent f07335d commit af4b558
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog/2823.bugfix.rst
@@ -0,0 +1 @@
Also accept tab after colon before factor filter expansion - by :user:`pdecat`.
5 changes: 3 additions & 2 deletions src/tox/config/loader/ini/factor.py
Expand Up @@ -49,8 +49,9 @@ def explode_factor(group: list[tuple[str, bool]]) -> str:
def expand_factors(value: str) -> Iterator[tuple[list[list[tuple[str, bool]]] | None, str]]:
for line in value.split("\n"):
factors: list[list[tuple[str, bool]]] | None = None
marker_at, content = line.find(":"), line
if marker_at != -1 and (len(line) == marker_at + 1 or line[marker_at + 1] == " "):
marker_search = re.search(r":(\s|$)", line)
marker_at, content = marker_search.start() if marker_search else -1, line
if marker_at != -1:
try:
factors = list(find_factor_groups(line[:marker_at].strip()))
except ValueError:
Expand Down
6 changes: 6 additions & 0 deletions tests/config/loader/ini/test_factor.py
Expand Up @@ -31,6 +31,8 @@ def complex_example() -> str:
extra: extra
more-default
no:space
trailingcolon:
tab:\ttab
""",
)

Expand All @@ -50,6 +52,8 @@ def test_factor_env_discover(complex_example: str) -> None:
"c",
"d",
"extra",
"trailingcolon",
"tab",
]


Expand All @@ -67,6 +71,8 @@ def test_factor_env_discover(complex_example: str) -> None:
"pi-b-dev",
"c",
"extra",
"trailingcolon",
"tab",
],
)
def test_factor_env_filter(env: str, complex_example: str) -> None:
Expand Down

0 comments on commit af4b558

Please sign in to comment.