Skip to content

Commit acac244

Browse files
authored
Handle whitespace around requirements (#2779)
Resolves #2773
1 parent d970c76 commit acac244

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
- id: pyupgrade
2626
files: "^(tests/demo_pkg_inline/build.py)$"
2727
- repo: https://github.com/PyCQA/isort
28-
rev: v5.11.3
28+
rev: 5.11.4
2929
hooks:
3030
- id: isort
3131
- repo: https://github.com/psf/black
@@ -78,7 +78,7 @@ repos:
7878
name: changelog filenames
7979
language: fail
8080
entry: "changelog files must be named ####.(feature|bugfix|doc|removal|misc).rst"
81-
exclude: ^docs/changelog/(\d+\.(feature|bugfix|doc|removal|misc).rst|README.rst|template.jinja2)
81+
exclude: ^docs/changelog/(\d+\.(feature|bugfix|doc|removal|misc).rst|template.jinja2)
8282
files: ^docs/changelog/
8383
- repo: meta
8484
hooks:

docs/changelog/2773.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Strip leading and trailing whitespace when parsing elements in requirement files - by :user:`gaborbernat`.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ optional-dependencies.docs = [
4242
"sphinx-copybutton>=0.5.1",
4343
"sphinx-inline-tabs>=2022.1.2b11",
4444
"sphinxcontrib-towncrier>=0.2.1a0",
45-
"towncrier>=22.8",
45+
"towncrier>=22.12",
4646
]
4747
optional-dependencies.testing = [
4848
"build[virtualenv]>=0.9",

src/tox/tox_env/python/pip/req/file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def _break_args_options(line: str) -> tuple[str, str]:
361361
else:
362362
args.append(token)
363363
options.pop(0)
364-
return " ".join(args), " ".join(options)
364+
return " ".join(args).strip(), " ".join(options)
365365

366366
@staticmethod
367367
def _join_lines(lines_enum: ReqFileLines) -> ReqFileLines:

tests/tox_env/python/pip/req/test_file.py

+7
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@
272272
["attrs"],
273273
id="sha512 hash is supported",
274274
),
275+
pytest.param(
276+
"\tp @ https://github.com/a/b/c/d.zip ",
277+
{},
278+
["p@ https://github.com/a/b/c/d.zip"],
279+
["p@ https://github.com/a/b/c/d.zip"],
280+
id="whitespace around",
281+
),
275282
]
276283

277284

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ passenv =
4343
PROGRAMDATA
4444
skip_install = true
4545
deps =
46-
pre-commit>=2.20
46+
pre-commit>=2.21
4747
commands =
4848
pre-commit run --all-files --show-diff-on-failure {posargs}
4949
python -c 'print(r"hint: run {envbindir}{/}pre-commit install to add checks as pre-commit hook")'
@@ -85,7 +85,7 @@ skip_install = true
8585
deps =
8686
gitpython>=3.1.29
8787
packaging>=22
88-
towncrier>=22.8
88+
towncrier>=22.12
8989
commands =
9090
python {toxinidir}/tasks/release.py --version {posargs}
9191

0 commit comments

Comments
 (0)