pylint: disable used-before-assignment

Related: https://pagure.io/freeipa/issue/9278

Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
Reviewed-By: Stanislav Levin <slev@altlinux.org>
This commit is contained in:
Florence Blanc-Renaud
2022-11-18 17:53:42 +01:00
parent a9c1c81a46
commit 2011d1a36a
9 changed files with 12 additions and 5 deletions

View File

@@ -63,7 +63,9 @@ def use_api_as_principal(principal, keytab):
finally:
if api.Backend.rpcclient.isconnected():
api.Backend.rpcclient.disconnect()
# pylint: disable=used-before-assignment
setattr(context, "principal", old_principal)
# pylint: enable=used-before-assignment
def parse_options():

View File

@@ -1101,7 +1101,7 @@ class LDAPClient:
except ldap.TYPE_OR_VALUE_EXISTS:
# attribute type or attribute value already exists, usually only
# occurs, when two machines try to write at the same time.
raise errors.DuplicateEntry(message=desc)
raise errors.DuplicateEntry(message=desc) # pylint: disable=E0601
except ldap.CONSTRAINT_VIOLATION:
# This error gets thrown by the uniqueness plugin
_msg = 'Another entry with the same attribute value already exists'

View File

@@ -391,6 +391,7 @@ class ADTRUSTInstance(service.Service):
try:
size = int(local_range.single_value.get('ipaIDRangeSize'))
except ValueError:
# pylint: disable=used-before-assignment
raise RuntimeError('ipaIDRangeSize is set to a non-integer '
'value or is not set at all (got {val})'
.format(val=size))

View File

@@ -1561,7 +1561,7 @@ def validate_mask():
try:
mask = os.umask(0)
finally:
os.umask(mask)
os.umask(mask) # pylint: disable=used-before-assignment
mask_str = None
if mask & 0b111101101 > 0:
mask_str = "{:04o}".format(mask)

View File

@@ -482,6 +482,7 @@ class KrbInstance(service.Service):
logger.error("Failed to initiate the request: %s", e)
return
finally:
# pylint: disable-next=used-before-assignment
if prev_helper is not None:
certmonger.modify_ca_helper(certmonger_ca, prev_helper)

View File

@@ -60,6 +60,7 @@ def use_keytab(principal, keytab):
'principal %s in %s: %s' % (principal, keytab,
str(e)))
finally:
# pylint: disable-next=used-before-assignment
setattr(context, 'principal', old_principal)

View File

@@ -663,7 +663,7 @@ class TestTrust(BaseTestTrust):
sssd_log2 = client.get_file_contents(log_file)[logsize:]
assert error.encode() not in sssd_log2
finally:
if stop_sssdbe.returncode == 0:
if stop_sssdbe.returncode == 0: # pylint: disable=E0601
self.master.run_command('kill -CONT %s' % pid)
# reconnect and set back to default extdom plugin
conn = self.master.ldap_connect()

View File

@@ -187,9 +187,11 @@ class CAACLTracker(Tracker):
if silent:
self.attrs.update(filtered_updates)
self.attrs.update(expected_updates)
# pylint: disable=used-before-assignment
self.check_update(result,
extra_keys=set(self.update_keys) |
set(expected_updates.keys()))
# pylint: enable=used-before-assignment
def check_update(self, result, extra_keys=()):
assert_deepequal(dict(

View File

@@ -202,7 +202,7 @@ class XMLRPC_test:
"""
@pytest.fixture(autouse=True, scope="class")
def xmlrpc_setup(self, request):
if not server_available:
if not server_available: # pylint: disable=used-before-assignment
pytest.skip('%r: Server not available: %r' %
(request.cls.__module__,
api.env.xmlrpc_uri))
@@ -353,7 +353,7 @@ class Declarative(XMLRPC_test):
raise AssertionError(
EXPECTED % (cmd, expected_name, args, options, output)
)
if not isinstance(got, klass):
if not isinstance(got, klass): # pylint: disable=used-before-assignment
raise AssertionError(
UNEXPECTED % (cmd, expected_name, args, options,
expected_name, expected,