From e463ca9dab0e04b1674a5dca00f22e9642149640 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Fri, 20 Dec 2024 15:42:02 -0800 Subject: [PATCH 1/2] Remove unused _urlopen method This was never used anywhere, and actually didn't even import - 'request' is actually urllib.request, not requests. It was never imported but used here! --- repo2docker/contentproviders/doi.py | 13 ------------- tests/unit/contentproviders/test_figshare.py | 1 - tests/unit/contentproviders/test_swhid.py | 4 ---- 3 files changed, 18 deletions(-) diff --git a/repo2docker/contentproviders/doi.py b/repo2docker/contentproviders/doi.py index cf43a1578..306248021 100644 --- a/repo2docker/contentproviders/doi.py +++ b/repo2docker/contentproviders/doi.py @@ -29,19 +29,6 @@ def _request(self, url, **kwargs): urlopen = _request - def _urlopen(self, req, headers=None): - """A urlopen() helper""" - # someone passed a string, not a request - if not isinstance(req, request.Request): - req = request.Request(req) - - req.add_header("User-Agent", f"repo2docker {__version__}") - if headers is not None: - for key, value in headers.items(): - req.add_header(key, value) - - return request.urlopen(req) - def doi2url(self, doi): # Transform a DOI to a URL # If not a doi, assume we have a URL and return diff --git a/tests/unit/contentproviders/test_figshare.py b/tests/unit/contentproviders/test_figshare.py index 760c0e487..9b8229e46 100644 --- a/tests/unit/contentproviders/test_figshare.py +++ b/tests/unit/contentproviders/test_figshare.py @@ -129,7 +129,6 @@ def test_fetch_zip(requests_mock): ) requests_mock.get(f"file://{fig_path}", content=open(fig_path, "rb").read()) - # with patch.object(Figshare, "urlopen", new=mock_urlopen): with TemporaryDirectory() as d: output = [] for l in test_fig.fetch(test_spec, d): diff --git a/tests/unit/contentproviders/test_swhid.py b/tests/unit/contentproviders/test_swhid.py index 56fee1dfc..0de5be68b 100644 --- a/tests/unit/contentproviders/test_swhid.py +++ b/tests/unit/contentproviders/test_swhid.py @@ -56,10 +56,6 @@ def test_detect(swhid, expected): assert provider.detect(swhid) == expected -def fake_urlopen(req): - print(req) - return req.headers - def test_unresolving_swhid(): provider = Swhid() From 0305dabdb634324898cb8679676da841e5b4d89a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:52:58 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/unit/contentproviders/test_swhid.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/contentproviders/test_swhid.py b/tests/unit/contentproviders/test_swhid.py index 0de5be68b..edf68af4b 100644 --- a/tests/unit/contentproviders/test_swhid.py +++ b/tests/unit/contentproviders/test_swhid.py @@ -56,7 +56,6 @@ def test_detect(swhid, expected): assert provider.detect(swhid) == expected - def test_unresolving_swhid(): provider = Swhid()