Skip to content

Commit e35547a

Browse files
WavyEbuilderstephensmalley
authored andcommitted
python: fix flake8 F824 error
This fixes failing CI[1]. From the flake8 documentation[2]: > global name / nonlocal name is unused: name is never assigned in scope Meaning that a global only needs to be defined with the global keyword in scope when it's being assigned to; not when it's being read. [1] https://github.com/SELinuxProject/selinux/actions/runs/16623315767/job/47032933729 [2] https://flake8.pycqa.org/en/latest/user/error-codes.html Signed-off-by: Rahul Sandhu <[email protected]> Acked-by: James Carter <[email protected]>
1 parent 847be2e commit e35547a

File tree

4 files changed

+3
-7
lines changed

4 files changed

+3
-7
lines changed

mcstrans/share/util/mlstrans-test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ errors = 0
88

99

1010
def untrans(trans, val):
11-
global errors, verbose
11+
global errors
1212
(rc, raw) = selinux.selinux_trans_to_raw_context(trans)
1313
if raw != val:
1414
print("untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val))
@@ -19,7 +19,7 @@ def untrans(trans, val):
1919

2020

2121
def trans(raw, val):
22-
global errors, verbose
22+
global errors
2323
(rc, trans) = selinux.selinux_raw_to_trans_context(raw)
2424
if trans != val:
2525
print("trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val))

python/semanage/seobject.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ class semanageRecords:
244244
args = None
245245

246246
def __init__(self, args = None):
247-
global handle
248247
if args:
249248
# legacy code - args was store originally
250249
if isinstance(args, str):

python/sepolgen/src/sepolgen/refparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ def p_quoted_filename(p):
10381038
#
10391039

10401040
def p_error(tok):
1041-
global error, parse_file, success, parser
1041+
global error, success
10421042
error = "%s: Syntax error on line %d %s [type=%s]" % (parse_file, tok.lineno, tok.value, tok.type)
10431043
print(error)
10441044
success = False

python/sepolicy/sepolicy/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def init_policy():
195195
policy(policy_file)
196196

197197
def info(setype, name=None):
198-
global _pol
199198
if not _pol:
200199
init_policy()
201200

@@ -354,7 +353,6 @@ def _setools_rule_to_dict(rule):
354353

355354

356355
def search(types, seinfo=None):
357-
global _pol
358356
if not _pol:
359357
init_policy()
360358
if not seinfo:
@@ -936,7 +934,6 @@ def get_all_roles():
936934
if roles:
937935
return roles
938936

939-
global _pol
940937
if not _pol:
941938
init_policy()
942939

0 commit comments

Comments
 (0)