Skip to content

Commit cd713f3

Browse files
committed
Fix linting issues
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent b6140b0 commit cd713f3

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/fetchcode/pypi.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ def get_download_url(cls, purl):
5050

5151
if not download_urls:
5252
raise ValueError(f"No download URLs found for {name} version {version}")
53-
54-
download_url = next(
55-
(url["url"] for url in download_urls if url.get("url")),
56-
None
57-
)
53+
54+
download_url = next((url["url"] for url in download_urls if url.get("url")), None)
5855

5956
if not download_url:
6057
raise ValueError(f"No download URL found for {name} version {version}")

tests/test_pypi.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import unittest
22
from unittest.mock import patch
3+
34
from fetchcode.pypi import Pypi
45

5-
class TestGetDownloadURL(unittest.TestCase):
66

7+
class TestGetDownloadURL(unittest.TestCase):
78
@patch("fetchcode.pypi.fetch_json_response")
89
def test_valid_purl_returns_download_url(self, mock_fetch_json_response):
910
mock_response = {
@@ -19,7 +20,7 @@ def test_valid_purl_returns_download_url(self, mock_fetch_json_response):
1920
result = Pypi.get_download_url(purl)
2021
self.assertEqual(
2122
result,
22-
"https://files.pythonhosted.org/packages/source/r/requests/requests-2.31.0.tar.gz"
23+
"https://files.pythonhosted.org/packages/source/r/requests/requests-2.31.0.tar.gz",
2324
)
2425

2526
@patch("fetchcode.pypi.fetch_json_response")
@@ -54,9 +55,7 @@ def test_empty_urls_list_raises_value_error(self, mock_fetch_json_response):
5455

5556
@patch("fetchcode.pypi.fetch_json_response")
5657
def test_first_url_object_missing_url_key(self, mock_fetch_json_response):
57-
mock_fetch_json_response.return_value = {
58-
"urls": [{}]
59-
}
58+
mock_fetch_json_response.return_value = {"urls": [{}]}
6059
purl = "pkg:pypi/requests@2.31.0"
6160
with self.assertRaises(ValueError) as context:
6261
Pypi.get_download_url(purl)
@@ -65,10 +64,7 @@ def test_first_url_object_missing_url_key(self, mock_fetch_json_response):
6564
@patch("fetchcode.pypi.fetch_json_response")
6665
def test_url_fallback_when_multiple_urls_provided(self, mock_fetch_json_response):
6766
mock_fetch_json_response.return_value = {
68-
"urls": [
69-
{},
70-
{"url": "https://example.com/fallback-url.tar.gz"}
71-
]
67+
"urls": [{}, {"url": "https://example.com/fallback-url.tar.gz"}]
7268
}
7369

7470
purl = "pkg:pypi/requests@2.31.0"

0 commit comments

Comments
 (0)