Skip to content

Commit

Permalink
fix index error for yanked releases without dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored and abn committed Nov 17, 2024
1 parent ebe7ada commit 6e1bf8b
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/poetry/repositories/http_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ def _get_info_from_metadata(self, link: Link) -> PackageInfo | None:
return None

def _get_info_from_links(
self,
links: list[Link],
*,
ignore_yanked: bool = True,
self, links: list[Link], *, ignore_yanked: bool
) -> PackageInfo:
# Sort links by distribution type
wheels: list[Link] = []
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _get_release_info(
# dependencies by introspecting packages.
page = self.get_page(name)
links = list(page.links_for_version(name, version))
info = self._get_info_from_links(links)
info = self._get_info_from_links(links, ignore_yanked=not data.yanked)

data.requires_dist = info.requires_dist

Expand Down
8 changes: 8 additions & 0 deletions tests/repositories/fixtures/distribution_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ class DistributionHash:
"cd2a17ac273fea8bf8953118a2d83bad94f592f0db3e83fff9129a1842e36dbe",
"0e8c1d7c14f309f6cd2dfd4e48e75cb1",
),
"isodate-0.7.0-py3-none-any.whl": DistributionHash(
"04505f97eb100b66dff1239859e6e04ab913714c453d6ab9591adbf418285847",
"1af9e3ee3f5669186356afd2dbe7ce81",
),
"isodate-0.7.0.tar.gz": DistributionHash(
"167c3615c0bd2e498c9bae7a1aba5863a17e52299aafd89f17a3a091187dca74",
"5668b7b7120797f03330363000afc35a",
),
"isort-4.3.4-py2-none-any.whl": DistributionHash(
"383c39c10b5db83e8d150ac5b84d74bda96e3a1b06a30257f022dcbcd21f54b9",
"42bccda292eca3c91eadf3eb781a224f",
Expand Down
2 changes: 2 additions & 0 deletions tests/repositories/fixtures/pypi.org/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ def cleanup_old_files(releases: dict[str, list[str]]) -> None:
Release("ipython", "7.5.0"),
],
),
# yanked, no dependencies
Project("isodate", releases=[Release("isodate", "0.7.0")]),
Project("isort", releases=[Release("isort", "4.3.4")]),
Project("jupyter", releases=[Release("jupyter", "1.0.0")]),
Project("more-itertools", releases=[Release("more-itertools", "4.1.0")]),
Expand Down
47 changes: 47 additions & 0 deletions tests/repositories/fixtures/pypi.org/json/isodate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"alternate-locations": [],
"files": [
{
"core-metadata": {
"sha256": "e7f80a7843aedda2ae25b1d351c9cbb50c16e45acf0596f7a6591e76d90049a4"
},
"data-dist-info-metadata": {
"sha256": "e7f80a7843aedda2ae25b1d351c9cbb50c16e45acf0596f7a6591e76d90049a4"
},
"filename": "isodate-0.7.0-py3-none-any.whl",
"hashes": {
"md5": "1af9e3ee3f5669186356afd2dbe7ce81",
"sha256": "04505f97eb100b66dff1239859e6e04ab913714c453d6ab9591adbf418285847"
},
"provenance": null,
"requires-python": null,
"size": 22286,
"upload-time": "2024-10-08T02:38:56.092325Z",
"url": "https://files.pythonhosted.org/packages/8f/90/7fba16c0bbee2ea71c135bbf5a905d4f7873ec982ffbe7305b30c555eec1/isodate-0.7.0-py3-none-any.whl",
"yanked": "fails for py2.7 but is not marked as py3 only."
},
{
"core-metadata": false,
"data-dist-info-metadata": false,
"filename": "isodate-0.7.0.tar.gz",
"hashes": {
"md5": "5668b7b7120797f03330363000afc35a",
"sha256": "167c3615c0bd2e498c9bae7a1aba5863a17e52299aafd89f17a3a091187dca74"
},
"provenance": null,
"requires-python": null,
"size": 29597,
"upload-time": "2024-10-08T02:38:58.140328Z",
"url": "https://files.pythonhosted.org/packages/9b/40/32ce777053517be3032bb2ab3bb216959071ee0c16c761879e75c34a323e/isodate-0.7.0.tar.gz",
"yanked": "fails for py2.7 but is not marked as py3 only."
}
],
"meta": {
"_last-serial": 0,
"api-version": "1.3"
},
"name": "isodate",
"versions": [
"0.7.0"
]
}
100 changes: 100 additions & 0 deletions tests/repositories/fixtures/pypi.org/json/isodate/0.7.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"info": {
"author": "Gerhard Weis",
"author_email": null,
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet",
"Topic :: Software Development :: Libraries :: Python Modules"
],
"description": "",
"description_content_type": "text/x-rst",
"docs_url": null,
"download_url": null,
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"dynamic": null,
"home_page": null,
"keywords": null,
"license": "Copyright (c) 2021, Hugo van Kemenade and contributors Copyright (c) 2009-2018, Gerhard Weis and contributors Copyright (c) 2009, Gerhard Weis All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
"license_expression": null,
"license_files": null,
"maintainer": null,
"maintainer_email": null,
"name": "isodate",
"package_url": "https://pypi.org/project/isodate/",
"platform": null,
"project_url": "https://pypi.org/project/isodate/",
"project_urls": {
"Homepage": "https://github.com/gweis/isodate/"
},
"provides_extra": null,
"release_url": "https://pypi.org/project/isodate/0.7.0/",
"requires_dist": null,
"requires_python": null,
"summary": "An ISO 8601 date/time/duration parser and formatter",
"version": "0.7.0",
"yanked": true,
"yanked_reason": "fails for py2.7 but is not marked as py3 only."
},
"last_serial": 0,
"urls": [
{
"comment_text": "",
"digests": {
"md5": "1af9e3ee3f5669186356afd2dbe7ce81",
"sha256": "04505f97eb100b66dff1239859e6e04ab913714c453d6ab9591adbf418285847"
},
"downloads": -1,
"filename": "isodate-0.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1af9e3ee3f5669186356afd2dbe7ce81",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 22286,
"upload_time": "2024-10-08T02:38:56",
"upload_time_iso_8601": "2024-10-08T02:38:56.092325Z",
"url": "https://files.pythonhosted.org/packages/8f/90/7fba16c0bbee2ea71c135bbf5a905d4f7873ec982ffbe7305b30c555eec1/isodate-0.7.0-py3-none-any.whl",
"yanked": true,
"yanked_reason": "fails for py2.7 but is not marked as py3 only."
},
{
"comment_text": "",
"digests": {
"md5": "5668b7b7120797f03330363000afc35a",
"sha256": "167c3615c0bd2e498c9bae7a1aba5863a17e52299aafd89f17a3a091187dca74"
},
"downloads": -1,
"filename": "isodate-0.7.0.tar.gz",
"has_sig": false,
"md5_digest": "5668b7b7120797f03330363000afc35a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 29597,
"upload_time": "2024-10-08T02:38:58",
"upload_time_iso_8601": "2024-10-08T02:38:58.140328Z",
"url": "https://files.pythonhosted.org/packages/9b/40/32ce777053517be3032bb2ab3bb216959071ee0c16c761879e75c34a323e/isodate-0.7.0.tar.gz",
"yanked": true,
"yanked_reason": "fails for py2.7 but is not marked as py3 only."
}
],
"vulnerabilities": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Metadata-Version: 2.1
Name: isodate
Version: 0.7.0
Summary: An ISO 8601 date/time/duration parser and formatter
Author: Gerhard Weis
License: Copyright (c) 2021, Hugo van Kemenade and contributors
Copyright (c) 2009-2018, Gerhard Weis and contributors
Copyright (c) 2009, Gerhard Weis
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Project-URL: Homepage, https://github.com/gweis/isodate/
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/x-rst
License-File: LICENSE

Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/repositories/test_pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ def test_package_yanked(
assert package.yanked_reason == yanked_reason


@pytest.mark.parametrize("fallback", [False, True])
def test_package_yanked_no_dependencies(
pypi_repository: PyPiRepository, fallback: bool
) -> None:
repo = pypi_repository
repo._fallback = fallback

package = repo.package("isodate", Version.parse("0.7.0"))

assert package.name == "isodate"
assert str(package.version) == "0.7.0"
assert package.yanked is True
assert package.yanked_reason == "fails for py2.7 but is not marked as py3 only."


def test_package_not_canonicalized(pypi_repository: PyPiRepository) -> None:
repo = pypi_repository

Expand Down

0 comments on commit 6e1bf8b

Please sign in to comment.