Skip to content

Commit 7039041

Browse files
authored
Merge pull request #1386 from consideRatio/pr/fix-flake8-warnings
Fix various flake8 warnings
2 parents 908d7a9 + 13978ab commit 7039041

File tree

17 files changed

+59
-59
lines changed

17 files changed

+59
-59
lines changed

binderhub/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def check_rate_limit(self):
118118
request_ip = self.request.remote_ip
119119
try:
120120
limit = rate_limiter.increment(request_ip)
121-
except RateLimitExceeded as e:
121+
except RateLimitExceeded:
122122
raise web.HTTPError(
123123
429,
124124
f"Rate limit exceeded. Try again in {rate_limiter.period_seconds} seconds.",

binderhub/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def submit(self):
412412
)
413413

414414
try:
415-
ret = self.api.create_namespaced_pod(
415+
_ = self.api.create_namespaced_pod(
416416
self.namespace,
417417
self.pod,
418418
_request_timeout=KUBE_REQUEST_TIMEOUT,
@@ -468,7 +468,7 @@ def submit(self):
468468
self.cleanup()
469469
elif self.pod.status.phase == 'Failed':
470470
self.cleanup()
471-
except Exception as e:
471+
except Exception:
472472
app_log.exception("Error in watch stream for %s", self.name)
473473
raise
474474
finally:
@@ -572,6 +572,6 @@ def stream_logs(self):
572572
self.progress(ProgressEvent.Kind.BUILD_STATUS_CHANGE, ProgressEvent.BuildStatus.COMPLETED)
573573
self.progress('log', json.dumps({
574574
'phase': 'Deleted',
575-
'message': f"Deleted...\n",
575+
'message': "Deleted...\n",
576576
})
577577
)

binderhub/build_local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ def submit(self):
186186
for line in _execute_cmd(cmd, capture=True, env=env):
187187
self._handle_log(line)
188188
self.progress(ProgressEvent.Kind.BUILD_STATUS_CHANGE, ProgressEvent.BuildStatus.COMPLETED)
189-
except subprocess.CalledProcessError as e:
189+
except subprocess.CalledProcessError:
190190
self.progress(ProgressEvent.Kind.BUILD_STATUS_CHANGE, ProgressEvent.BuildStatus.FAILED)
191-
except Exception as e:
191+
except Exception:
192192
app_log.exception("Error in watch stream for %s", self.name)
193193
raise
194194

binderhub/health.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def wrapper(*args, **kwargs):
2525
while attempts > 0:
2626
try:
2727
return await f(*args, **kwargs)
28-
except Exception as e:
28+
except Exception:
2929
if attempts == 1:
3030
raise
3131
else:
@@ -47,7 +47,7 @@ def false_if_raises(f):
4747
async def wrapper(*args, **kwargs):
4848
try:
4949
res = await f(*args, **kwargs)
50-
except Exception as e:
50+
except Exception:
5151
app_log.exception(f"Error checking {f.__name__}")
5252
res = False
5353
return res

binderhub/launcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def _default_hub_url_local(self):
7373
config=True,
7474
allow_none=True,
7575
help="""
76-
An optional hook function that you can use to implement checks before starting a user's server.
77-
For example if you have a non-standard BinderHub deployment,
76+
An optional hook function that you can use to implement checks before starting a user's server.
77+
For example if you have a non-standard BinderHub deployment,
7878
in this hook you can check if the current user has right to launch a new repo.
79-
79+
8080
Receives 5 parameters: launcher, image, username, server_name, repo_url
8181
"""
8282
)

binderhub/tests/test_launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async def test_pre_launch_hook():
1414
launcher = Launcher(create_user=False, pre_launch_hook=my_pre_launch_hook)
1515
parameters = ['image', 'test_user', 'test_server', 'repo_url']
1616
with pytest.raises(web.HTTPError) as excinfo:
17-
server_info = await launcher.launch(*parameters)
17+
_ = await launcher.launch(*parameters)
1818
assert excinfo.value.status_code == 400
1919
message = excinfo.value.log_message
2020
assert parameters == message.split(':', 1)[-1].lstrip().split(',')

binderhub/tests/test_ratelimit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def test_rate_limit_expires():
3737
r = RateLimiter(limit=10, period_seconds=60)
3838
assert r._limits == {}
3939
now = r.time()
40-
reset = int(now) + 60
4140

4241
for i in range(5):
4342
limit = r.increment("1.2.3.4")
@@ -56,7 +55,7 @@ def test_rate_limit_clean():
5655
assert r._limits == {}
5756
now = r.time()
5857

59-
limit = r.increment("1.2.3.4")
58+
r.increment("1.2.3.4")
6059

6160
with mock.patch.object(r, "time", lambda: now + 30):
6261
limit2 = r.increment("4.3.2.1")

binderhub/tests/test_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def initialize(self, test_handle):
6767
self.test_handle = test_handle
6868

6969
def get(self):
70-
scope = self.get_argument("scope")
70+
self.get_argument("scope")
7171
auth_header = self.request.headers.get("Authorization", "")
7272
if not auth_header.startswith("Basic "):
7373
raise HTTPError(401, "No basic auth")

binderhub/tests/test_repoproviders.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def test_github_ref(repo, unresolved_ref, resolved_ref):
199199
full_url = provider.get_repo_url()
200200
assert full_url == f"https://github.com/{repo}"
201201
ref = IOLoop().run_sync(provider.get_resolved_ref)
202-
if resolved_ref == True:
202+
if resolved_ref is True:
203203
# True means it should resolve, but don't check value
204204
assert ref is not None
205205
assert is_valid_sha1(ref)
@@ -353,7 +353,7 @@ def test_long_spec(self):
353353

354354
def test_spec_with_no_suggestion(self):
355355
spec = "short/master"
356-
error = "^((?!Did you mean).)*$".format(spec) # negative match
356+
error = "^((?!Did you mean).)*$" # negative match
357357
with self.assertRaisesRegex(ValueError, error):
358358
user, repo, unresolved_ref = tokenize_spec(spec)
359359

@@ -393,7 +393,7 @@ def test_git_ref(url, unresolved_ref, resolved_ref):
393393
full_url = provider.get_repo_url()
394394
assert full_url == url
395395
ref = IOLoop().run_sync(provider.get_resolved_ref)
396-
if resolved_ref == True:
396+
if resolved_ref is True:
397397
# True means it should resolve, but don't check value
398398
assert ref is not None
399399
assert is_valid_sha1(ref)
@@ -461,7 +461,7 @@ def test_gitlab_ref(unresolved_ref, resolved_ref):
461461
full_url = provider.get_repo_url()
462462
assert full_url == f'https://gitlab.com/{namespace}.git'
463463
ref = IOLoop().run_sync(provider.get_resolved_ref)
464-
if resolved_ref == True:
464+
if resolved_ref is True:
465465
# True means it should resolve, but don't check value
466466
assert ref is not None
467467
assert is_valid_sha1(ref)
@@ -501,7 +501,7 @@ def test_gist_ref(owner, gist_id, unresolved_ref, resolved_ref):
501501
full_url = provider.get_repo_url()
502502
assert full_url == f"https://gist.github.com/{owner}/{gist_id}.git"
503503
ref = IOLoop().run_sync(provider.get_resolved_ref)
504-
if resolved_ref == True:
504+
if resolved_ref is True:
505505
# True means it should resolve, but don't check value
506506
assert ref is not None
507507
assert is_valid_sha1(ref)

binderhub/tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def test_ip_in_networks(ip, cidrs, found):
131131
assert message == f"message {net}"
132132
assert ipaddress.ip_address(ip) in net
133133
else:
134-
assert match == False
134+
assert match is False
135135

136136

137137
def test_ip_in_networks_invalid():

0 commit comments

Comments
 (0)