Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also accept tab after colon before factor filter expansion #2823

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2823.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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