From 2011d1a36ac17449affbbcebc1fbeff19b270a42 Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Fri, 18 Nov 2022 17:53:42 +0100 Subject: [PATCH] pylint: disable used-before-assignment Related: https://pagure.io/freeipa/issue/9278 Signed-off-by: Florence Blanc-Renaud Reviewed-By: Stanislav Levin --- ipaclient/install/ipa_client_samba.py | 2 ++ ipapython/ipaldap.py | 2 +- ipaserver/install/adtrustinstance.py | 1 + ipaserver/install/installutils.py | 2 +- ipaserver/install/krbinstance.py | 1 + ipatests/test_cmdline/test_ipagetkeytab.py | 1 + ipatests/test_integration/test_trust.py | 2 +- ipatests/test_xmlrpc/tracker/caacl_plugin.py | 2 ++ ipatests/test_xmlrpc/xmlrpc_test.py | 4 ++-- 9 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ipaclient/install/ipa_client_samba.py b/ipaclient/install/ipa_client_samba.py index d36f568e4..82d945f2c 100755 --- a/ipaclient/install/ipa_client_samba.py +++ b/ipaclient/install/ipa_client_samba.py @@ -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(): diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index 0ffaf4d7e..2f7ef3f94 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -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' diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py index bf0cc3b09..518a30a07 100644 --- a/ipaserver/install/adtrustinstance.py +++ b/ipaserver/install/adtrustinstance.py @@ -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)) diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 36b04e870..aaa6fd112 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -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) diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py index dc77050b9..4980de15c 100644 --- a/ipaserver/install/krbinstance.py +++ b/ipaserver/install/krbinstance.py @@ -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) diff --git a/ipatests/test_cmdline/test_ipagetkeytab.py b/ipatests/test_cmdline/test_ipagetkeytab.py index 280a97f77..4cda88a11 100755 --- a/ipatests/test_cmdline/test_ipagetkeytab.py +++ b/ipatests/test_cmdline/test_ipagetkeytab.py @@ -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) diff --git a/ipatests/test_integration/test_trust.py b/ipatests/test_integration/test_trust.py index 21c814ff1..653d86690 100644 --- a/ipatests/test_integration/test_trust.py +++ b/ipatests/test_integration/test_trust.py @@ -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() diff --git a/ipatests/test_xmlrpc/tracker/caacl_plugin.py b/ipatests/test_xmlrpc/tracker/caacl_plugin.py index cbafaf97c..7b55b04be 100644 --- a/ipatests/test_xmlrpc/tracker/caacl_plugin.py +++ b/ipatests/test_xmlrpc/tracker/caacl_plugin.py @@ -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( diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py index 83c5b2ce8..abf3b8beb 100644 --- a/ipatests/test_xmlrpc/xmlrpc_test.py +++ b/ipatests/test_xmlrpc/xmlrpc_test.py @@ -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,