Skip to content

Commit

Permalink
Handle whitespace around requirements (#2779)
Browse files Browse the repository at this point in the history
Resolves #2773
  • Loading branch information
gaborbernat committed Dec 26, 2022
1 parent d970c76 commit acac244
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -25,7 +25,7 @@ repos:
- id: pyupgrade
files: "^(tests/demo_pkg_inline/build.py)$"
- repo: https://github.com/PyCQA/isort
rev: v5.11.3
rev: 5.11.4
hooks:
- id: isort
- repo: https://github.com/psf/black
Expand Down Expand Up @@ -78,7 +78,7 @@ repos:
name: changelog filenames
language: fail
entry: "changelog files must be named ####.(feature|bugfix|doc|removal|misc).rst"
exclude: ^docs/changelog/(\d+\.(feature|bugfix|doc|removal|misc).rst|README.rst|template.jinja2)
exclude: ^docs/changelog/(\d+\.(feature|bugfix|doc|removal|misc).rst|template.jinja2)
files: ^docs/changelog/
- repo: meta
hooks:
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/2773.bugfix.rst
@@ -0,0 +1 @@
Strip leading and trailing whitespace when parsing elements in requirement files - by :user:`gaborbernat`.
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -42,7 +42,7 @@ optional-dependencies.docs = [
"sphinx-copybutton>=0.5.1",
"sphinx-inline-tabs>=2022.1.2b11",
"sphinxcontrib-towncrier>=0.2.1a0",
"towncrier>=22.8",
"towncrier>=22.12",
]
optional-dependencies.testing = [
"build[virtualenv]>=0.9",
Expand Down
2 changes: 1 addition & 1 deletion src/tox/tox_env/python/pip/req/file.py
Expand Up @@ -361,7 +361,7 @@ def _break_args_options(line: str) -> tuple[str, str]:
else:
args.append(token)
options.pop(0)
return " ".join(args), " ".join(options)
return " ".join(args).strip(), " ".join(options)

@staticmethod
def _join_lines(lines_enum: ReqFileLines) -> ReqFileLines:
Expand Down
7 changes: 7 additions & 0 deletions tests/tox_env/python/pip/req/test_file.py
Expand Up @@ -272,6 +272,13 @@
["attrs"],
id="sha512 hash is supported",
),
pytest.param(
"\tp @ https://github.com/a/b/c/d.zip ",
{},
["p@ https://github.com/a/b/c/d.zip"],
["p@ https://github.com/a/b/c/d.zip"],
id="whitespace around",
),
]


Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Expand Up @@ -43,7 +43,7 @@ passenv =
PROGRAMDATA
skip_install = true
deps =
pre-commit>=2.20
pre-commit>=2.21
commands =
pre-commit run --all-files --show-diff-on-failure {posargs}
python -c 'print(r"hint: run {envbindir}{/}pre-commit install to add checks as pre-commit hook")'
Expand Down Expand Up @@ -85,7 +85,7 @@ skip_install = true
deps =
gitpython>=3.1.29
packaging>=22
towncrier>=22.8
towncrier>=22.12
commands =
python {toxinidir}/tasks/release.py --version {posargs}

Expand Down

0 comments on commit acac244

Please sign in to comment.