Skip to content

Commit 9dfe312

Browse files
authored
remove unused callback argument in fetch (#900)
remove unused callback argument in fetch
2 parents 0926939 + 4b8b40e commit 9dfe312

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

nbviewer/providers/github/client.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def authenticate(self):
3636
'access_token': os.environ.get('GITHUB_API_TOKEN', ''),
3737
}
3838

39-
def fetch(self, url, callback=None, params=None, **kwargs):
39+
def fetch(self, url, params=None, **kwargs):
4040
"""Add GitHub auth to self.client.fetch"""
4141
if not url.startswith(self.github_api_url):
4242
raise ValueError(
@@ -54,7 +54,7 @@ def fetch(self, url, callback=None, params=None, **kwargs):
5454
headers['Authorization'] = 'token ' + self.auth['access_token']
5555

5656
url = url_concat(url, params)
57-
future = self.client.fetch(url, callback, **kwargs)
57+
future = self.client.fetch(url, **kwargs)
5858
future.add_done_callback(self._log_rate_limit)
5959
return future
6060

@@ -99,39 +99,39 @@ def _log_rate_limit(self, future):
9999
log = app_log.warn
100100
log("%i/%i GitHub API requests remaining", remaining, limit)
101101

102-
def github_api_request(self, path, callback=None, **kwargs):
102+
def github_api_request(self, path, **kwargs):
103103
"""Make a GitHub API request to URL
104104
105105
URL is constructed from url and params, if specified.
106-
callback and **kwargs are passed to client.fetch unmodified.
106+
**kwargs are passed to client.fetch unmodified.
107107
"""
108108
url = url_path_join(self.github_api_url, quote(path))
109-
return self.fetch(url, callback, **kwargs)
109+
return self.fetch(url, **kwargs)
110110

111-
def get_gist(self, gist_id, callback=None, **kwargs):
111+
def get_gist(self, gist_id, **kwargs):
112112
"""Get a gist"""
113113
path = u'gists/{}'.format(gist_id)
114-
return self.github_api_request(path, callback, **kwargs)
114+
return self.github_api_request(path, **kwargs)
115115

116-
def get_contents(self, user, repo, path, callback=None, ref=None, **kwargs):
116+
def get_contents(self, user, repo, path, ref=None, **kwargs):
117117
"""Make contents API request - either file contents or directory listing"""
118118
path = u'repos/{user}/{repo}/contents/{path}'.format(**locals())
119119
if ref is not None:
120120
params = kwargs.setdefault('params', {})
121121
params['ref'] = ref
122-
return self.github_api_request(path, callback, **kwargs)
122+
return self.github_api_request(path, **kwargs)
123123

124-
def get_repos(self, user, callback=None, **kwargs):
124+
def get_repos(self, user, **kwargs):
125125
"""List a user's repos"""
126126
path = u"users/{user}/repos".format(user=user)
127-
return self.github_api_request(path, callback, **kwargs)
127+
return self.github_api_request(path, **kwargs)
128128

129-
def get_gists(self, user, callback=None, **kwargs):
129+
def get_gists(self, user, **kwargs):
130130
"""List a user's gists"""
131131
path = u"users/{user}/gists".format(user=user)
132-
return self.github_api_request(path, callback, **kwargs)
132+
return self.github_api_request(path, **kwargs)
133133

134-
def get_tree(self, user, repo, path, ref='master', recursive=False, callback=None, **kwargs):
134+
def get_tree(self, user, repo, path, ref='master', recursive=False, **kwargs):
135135
"""Get a git tree"""
136136
# only need a recursive fetch if it's not in the top-level dir
137137
if '/' in path:
@@ -140,18 +140,18 @@ def get_tree(self, user, repo, path, ref='master', recursive=False, callback=Non
140140
if recursive:
141141
params = kwargs.setdefault('params', {})
142142
params['recursive'] = True
143-
tree = self.github_api_request(path, callback, **kwargs)
143+
tree = self.github_api_request(path, **kwargs)
144144
return tree
145145

146-
def get_branches(self, user, repo, callback=None, **kwargs):
146+
def get_branches(self, user, repo, **kwargs):
147147
"""List a repo's branches"""
148148
path = u"repos/{user}/{repo}/branches".format(user=user, repo=repo)
149-
return self.github_api_request(path, callback, **kwargs)
149+
return self.github_api_request(path, **kwargs)
150150

151-
def get_tags(self, user, repo, callback=None, **kwargs):
151+
def get_tags(self, user, repo, **kwargs):
152152
"""List a repo's branches"""
153153
path = u"repos/{user}/{repo}/tags".format(user=user, repo=repo)
154-
return self.github_api_request(path, callback, **kwargs)
154+
return self.github_api_request(path, **kwargs)
155155

156156
def extract_tree_entry(self, path, tree_response):
157157
"""extract a single tree entry from

nbviewer/providers/url/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ class NBViewerAsyncHTTPClient(object):
5454
def __init__(self, client=None):
5555
self.client = client or CurlAsyncHTTPClient()
5656

57-
def fetch(self, url, callback=None, params=None, **kwargs):
57+
def fetch(self, url, params=None, **kwargs):
5858
request = HTTPRequest(url, **kwargs)
5959

6060
if request.user_agent is None:
6161
request.user_agent = 'Tornado-Async-Client'
6262

6363
# The future which will become the response upon awaiting.
64-
response_future = asyncio.ensure_future(self.smart_fetch(request, callback))
64+
response_future = asyncio.ensure_future(self.smart_fetch(request))
6565

6666
return response_future
6767

68-
async def smart_fetch(self, request, callback):
68+
async def smart_fetch(self, request):
6969
"""
7070
Before fetching request, first look to see whether it's already in cache.
7171
If so load the response from cache. Only otherwise attempt to fetch the request.
@@ -95,7 +95,7 @@ async def smart_fetch(self, request, callback):
9595
else:
9696
app_log.info("Upstream cache miss %s", name)
9797

98-
response = await self.client.fetch(request, callback)
98+
response = await self.client.fetch(request)
9999
dt = time.time() - tic
100100
app_log.info("Fetched %s in %.2f ms", name, 1e3 * dt)
101101
await self._cache_response(cache_key, name, response)
@@ -112,7 +112,7 @@ async def _get_cached_response(self, cache_key, name):
112112
return pickle.loads(cached_pickle)
113113
except Exception:
114114
app_log.error("Upstream cache get failed %s", name, exc_info=True)
115-
115+
116116
async def _cache_response(self, cache_key, name, response):
117117
"""Cache the response, if any cache headers we understand are present."""
118118
if not self.cache:

0 commit comments

Comments
 (0)