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

Require space after colon before factor expansion #2822

Merged
merged 5 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2822.bugfix.rst
@@ -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
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] == " "):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat Should tabs be accepted too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitted #2823

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
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