Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused _urlopen method #1392

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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!
yuvipanda committed Dec 20, 2024
commit e463ca9dab0e04b1674a5dca00f22e9642149640
13 changes: 0 additions & 13 deletions repo2docker/contentproviders/doi.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tests/unit/contentproviders/test_figshare.py
Original file line number Diff line number Diff line change
@@ -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):
4 changes: 0 additions & 4 deletions tests/unit/contentproviders/test_swhid.py
Original file line number Diff line number Diff line change
@@ -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()