diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d694fdd8..d153df00d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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: diff --git a/docs/changelog/2773.bugfix.rst b/docs/changelog/2773.bugfix.rst new file mode 100644 index 000000000..e5bd6d498 --- /dev/null +++ b/docs/changelog/2773.bugfix.rst @@ -0,0 +1 @@ +Strip leading and trailing whitespace when parsing elements in requirement files - by :user:`gaborbernat`. diff --git a/pyproject.toml b/pyproject.toml index 1d966aa16..a3f37aa50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/src/tox/tox_env/python/pip/req/file.py b/src/tox/tox_env/python/pip/req/file.py index a37e24cce..d8b295589 100644 --- a/src/tox/tox_env/python/pip/req/file.py +++ b/src/tox/tox_env/python/pip/req/file.py @@ -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: diff --git a/tests/tox_env/python/pip/req/test_file.py b/tests/tox_env/python/pip/req/test_file.py index a24394d77..9e4e51a2c 100644 --- a/tests/tox_env/python/pip/req/test_file.py +++ b/tests/tox_env/python/pip/req/test_file.py @@ -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", + ), ] diff --git a/tox.ini b/tox.ini index 24b5fa32c..a534bedaf 100644 --- a/tox.ini +++ b/tox.ini @@ -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")' @@ -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}