Skip to content

Commit 4ec10ed

Browse files
committed
py: remove unnecessary globals
The github linter decided to become strict about unnecessary globals (when variable isn't overwritten). Remove those. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c9f6441 commit 4ec10ed

File tree

8 files changed

+1
-36
lines changed

8 files changed

+1
-36
lines changed

contest/backend/query.py

-8
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def hello():
2626

2727
@app.route('/branches')
2828
def branches():
29-
global psql
30-
3129
with psql.cursor() as cur:
3230
cur.execute(f"SELECT branch, t_date, base, url FROM branches ORDER BY t_date DESC LIMIT 40")
3331
rows = [{"branch": r[0], "date": r[1].isoformat() + "+00:00", "base": r[2], "url": r[3]} for r in cur.fetchall()]
@@ -36,8 +34,6 @@ def branches():
3634

3735

3836
def branches_to_rows(br_cnt, remote, br_pfx=None):
39-
global psql
40-
4137
cnt = 0
4238
with psql.cursor() as cur:
4339
remote_k = ",remote" if remote else ""
@@ -77,8 +73,6 @@ def result_as_l2(raw):
7773

7874
@app.route('/results')
7975
def results():
80-
global psql
81-
8276
limit = 0
8377
where = []
8478
log = ""
@@ -151,8 +145,6 @@ def results():
151145

152146
@app.route('/remotes')
153147
def remotes():
154-
global psql
155-
156148
t1 = datetime.datetime.now()
157149

158150
with psql.cursor() as cur:

core/lifetime.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def sig_init():
2323

2424
if not sig_initialized:
2525
signal.signal(signal.SIGUSR1, sig_handler)
26+
sig_initialized = True
2627

2728

2829
def nipa_git_version():
@@ -55,8 +56,6 @@ def __init__(self, config):
5556
self._restart = False
5657

5758
def next_poll(self, wait_time=None):
58-
global got_sigusr1
59-
6059
if self._first_run:
6160
self._first_run = False
6261
return True

core/logger.py

-8
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,16 @@ def log_init(name, path, force_single_thread=False):
220220

221221

222222
def log_fini():
223-
global tls
224-
225223
tls.logger.fini()
226224

227225

228226
def log_open_sec(header):
229-
global tls
230-
231227
tls.logger.open_sec(header)
232228

233229

234230
def log_end_sec():
235-
global tls
236-
237231
tls.logger.end_sec()
238232

239233

240234
def log(header, data=''):
241-
global tls
242-
243235
tls.logger.log(header, data)

mailbot.py

-10
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ def _resolve_authorized(self, pw):
317317
continue
318318
file_names.add(line[6:])
319319

320-
global maintainers
321320
maintainer_matches = maintainers.find_by_paths(file_names).find_by_owner(self.msg.get('From'))
322321
if len(maintainer_matches):
323322
self._authorized = repr(maintainer_matches)
@@ -340,7 +339,6 @@ def auto_awaiting_upstream(self):
340339
return False
341340
tags = subject[1:tags_end]
342341

343-
global auto_awaiting_upstream
344342
for designation in auto_awaiting_upstream:
345343
if designation in tags:
346344
return True
@@ -538,7 +536,6 @@ def handler(signum, _):
538536

539537

540538
def pw_state_log(fields):
541-
global config
542539
log_name = config.get('mailbot', 'change-log')
543540
if not log_name:
544541
return
@@ -551,8 +548,6 @@ def pw_state_log(fields):
551548

552549

553550
def weak_act_should_ignore(msg, series, want):
554-
global pw_act_active
555-
556551
if msg.user_authorized():
557552
return None
558553
current = series.state()
@@ -652,7 +647,6 @@ def do_mail_file(msg_path, pw, dr):
652647
try:
653648
do_mail(msg, pw, dr)
654649
except MlDelayActions as e:
655-
global delay_actions
656650
msg.flush_actions() # avoid duplicates, actions will get re-parsed
657651
delay_actions.append((e.when, msg, ))
658652

@@ -717,15 +711,12 @@ def main():
717711
if ua:
718712
http_headers = {"user-agent":ua}
719713

720-
global authorized_users
721714
users = config.get('mailbot', 'authorized')
722715
authorized_users.update(set(users.split(',')))
723716

724-
global auto_changes_requested
725717
users = config.get('mailbot', 'error-bots')
726718
auto_changes_requested.update(set(users.split(',')))
727719

728-
global auto_awaiting_upstream
729720
users = config.get('mailbot', 'awaiting-upstream')
730721
auto_awaiting_upstream.update(set(users.split(',')))
731722

@@ -746,7 +737,6 @@ def main():
746737
doc_load_time = datetime.datetime.fromtimestamp(0)
747738
dr = None
748739

749-
global should_stop
750740
while not should_stop:
751741
req_time = datetime.datetime.now()
752742

pw_brancher.py

-2
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ def apply_local_patches(config, tree) -> List:
177177

178178

179179
def db_insert(config, state, name):
180-
global psql_conn
181-
182180
# Branches usually have a trailing separator
183181
pfx = config.get("target", "branch_pfx")[:-1]
184182
pub_url = config.get('target', 'public_url')

pw_upload.py

-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ def initial_scan(self):
166166
break
167167

168168
def watch(self):
169-
global should_stop
170-
171169
if self.main_wd is None:
172170
raise Exception('Not initialized')
173171

system-status.py

-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ def pre_strip(line, needle):
5151

5252

5353
def add_one_tree(result, pfx, name):
54-
global char_filter
55-
5654
log_file = os.path.join(pfx, name)
5755
stat = os.stat(log_file)
5856

tests/patch/cc_maintainers/test.py

-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ def is_stale(self, e, since_months, dbg=None):
116116

117117

118118
def get_stale(sender_from, missing, out):
119-
global stale_db
120-
121119
sender_corp = None
122120
for corp in corp_suffix:
123121
if sender_from.endswith(corp):

0 commit comments

Comments
 (0)