Skip to content

Commit 2141633

Browse files
committed
Fix python codestyle and typing issues
1 parent 999d22f commit 2141633

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

judge/runguard_test/print_envvars.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#!/usr/bin/python3
2-
32
import os
43

54
envvars = os.environ.items()
65
print(f'COUNT: {len(envvars)}.')
76
for k, v in envvars:
87
print(f'{k}={v}')
9-

misc-tools/dj_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def parse_api_response(name: str, response: requests.Response):
4747
# We got a successful HTTP response. It worked. Return the full response
4848
try:
4949
result = json.loads(response.text)
50-
except json.decoder.JSONDecodeError as e:
50+
except json.decoder.JSONDecodeError:
5151
print(response.text)
5252
raise RuntimeError(f'Failed to JSON decode the response for API request {name}')
5353

@@ -87,7 +87,9 @@ def do_api_request(name: str, method: str = 'GET', jsonData: dict = {}):
8787
response = requests.get(url, headers=headers, verify=ca_check, auth=auth)
8888
elif method == 'PUT':
8989
response = requests.put(url, headers=headers, verify=ca_check, json=jsonData, auth=auth)
90-
except requests.exceptions.SSLError as e:
90+
else:
91+
raise RuntimeError("Method not supported")
92+
except requests.exceptions.SSLError:
9193
ca_check = not confirm(
9294
"Can not verify certificate, ignore certificate check?", False)
9395
if ca_check:
@@ -99,6 +101,7 @@ def do_api_request(name: str, method: str = 'GET', jsonData: dict = {}):
99101
raise RuntimeError(e)
100102
return parse_api_response(name, response)
101103

104+
102105
def upload_file(name: str, apifilename: str, file: str, data: dict = {}):
103106
'''Upload the given file to the API at the given path with the given name.
104107
@@ -128,7 +131,7 @@ def upload_file(name: str, apifilename: str, file: str, data: dict = {}):
128131
try:
129132
response = requests.post(
130133
url, files=files, headers=headers, data=data, verify=ca_check)
131-
except requests.exceptions.SSLError as e:
134+
except requests.exceptions.SSLError:
132135
ca_check = not confirm(
133136
"Can not verify certificate, ignore certificate check?", False)
134137
if ca_check:

submit/submit

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ drop-down box in the web interface.'''
259259
language_part = 'For LANGUAGE use the ID or a common extension.'
260260
else:
261261
language_part = 'For LANGUAGE use one of the following IDs or extensions:'
262-
max_length = max([len(L['name']) for L in languages])
262+
max_length = max([len(lang['name']) for lang in languages])
263263
for language in languages:
264264
sorted_exts = ', '.join(sorted(language['extensions']))
265265
language_part += f"\n {language['name']:<{max_length}} - {sorted_exts}"
@@ -377,8 +377,7 @@ parser.add_argument('-c', '--contest', help='''submit for contest with ID or sho
377377
parser.add_argument('-p', '--problem', help='submit for problem with ID or label PROBLEM', default='')
378378
parser.add_argument('-l', '--language', help='submit in language with ID LANGUAGE', default='')
379379
parser.add_argument('-e', '--entry_point', help='set an explicit entry_point, e.g. the java main class')
380-
parser.add_argument('-v', '--verbose',
381-
help='increase verbosity', choices=loglevels.keys(), nargs='?', const='INFO', default='WARNING')
380+
parser.add_argument('-v', '--verbose', help='increase verbosity', choices=loglevels.keys(), nargs='?', const='INFO', default='WARNING') # NOQA
382381
parser.add_argument('-q', '--quiet', help='suppress warning/info messages', action='store_true')
383382
parser.add_argument('-y', '--assume-yes', help='suppress user input and assume yes', action='store_true')
384383
parser.add_argument('-u', '--url', help='''submit to server with base address URL

0 commit comments

Comments
 (0)