diff options
author | Bernát Gábor <gaborjbernat@gmail.com> | 2022-12-26 17:09:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-26 09:09:40 -0800 |
commit | acac244f85172dc1a4ad3e9fe2b9cfcbd7ce5e6d (patch) | |
tree | aa4c12b4e76a6a8decd271a20bf1942d8abe7e3e | |
parent | d970c765a68b71bff56283eb6fa5aef17c5e97fc (diff) | |
download | tox-git-acac244f85172dc1a4ad3e9fe2b9cfcbd7ce5e6d.tar.gz |
Handle whitespace around requirements (#2779)
Resolves https://github.com/tox-dev/tox/issues/2773
-rw-r--r-- | .pre-commit-config.yaml | 4 | ||||
-rw-r--r-- | docs/changelog/2773.bugfix.rst | 1 | ||||
-rw-r--r-- | pyproject.toml | 2 | ||||
-rw-r--r-- | src/tox/tox_env/python/pip/req/file.py | 2 | ||||
-rw-r--r-- | tests/tox_env/python/pip/req/test_file.py | 7 | ||||
-rw-r--r-- | tox.ini | 4 |
6 files changed, 14 insertions, 6 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d694fdd..d153df00 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 00000000..e5bd6d49 --- /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 1d966aa1..a3f37aa5 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 a37e24cc..d8b29558 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 @@ class RequirementsFile: 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 a24394d7..9e4e51a2 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 @@ _REQ_FILE_TEST_CASES = [ ["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", + ), ] @@ -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} |