Skip to content

Commit

Permalink
[pylint] re-enable the following checks
Browse files Browse the repository at this point in the history
  - possibly-used-before-assignment
  - use-a-generator

Signed-off-by: Ponnuvel Palaniyappan <[email protected]>
  • Loading branch information
pponnuvel authored and TurboTurtle committed Aug 2, 2024
1 parent b5403ae commit d3a2169
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
2 changes: 0 additions & 2 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ disable=
W1201, # logging-not-lazy
W0707, # raise-missing-from
W0237, # arguments-renamed
E0606, # possibly-used-before-assignment
R1729, # use-a-generator
C0117, # unnecessary-negation
W0212, # protected-access
R1728, # consider-using-generator
Expand Down
6 changes: 3 additions & 3 deletions sos/cleaner/mappings/hostname_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def domain_name_in_loaded_domains(self, domain):
if len(host) == 1:
# don't block on host's shortname
return host[0] in self.hosts
if any([no_tld.endswith(_d) for _d in self._domains]):
if any(no_tld.endswith(_d) for _d in self._domains):
return True

return False
Expand Down Expand Up @@ -194,7 +194,7 @@ def sanitize_item(self, item):
if len(host) == 2:
# we have just a domain name, e.g. example.com
dname = self.sanitize_domain(host)
if all([h.isupper() for h in host]):
if all(h.isupper() for h in host):
dname = dname.upper()
return dname
if len(host) > 2:
Expand All @@ -213,7 +213,7 @@ def sanitize_item(self, item):
ob_domain = self.sanitize_domain(domain)
self.dataset[item] = ob_domain
_fqdn = '.'.join([ob_hostname, ob_domain])
if all([h.isupper() for h in host]):
if all(h.isupper() for h in host):
_fqdn = _fqdn.upper()
return _fqdn
return None
Expand Down
8 changes: 4 additions & 4 deletions sos/cleaner/mappings/ipv6_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,19 @@ def obfuscate_host_address(self, addr):
:returns: An obfuscated address within this network
:rtype: ``str``
"""
def _generate_address():
def _generate_address(host):
return ''.join([
self._obfuscated_network,
':'.join(generate_hextets(_host.split(':')))
':'.join(generate_hextets(host.split(':')))
])

if addr.compressed not in self.hosts:
# separate host from the address by removing its network prefix
_n = self.network_addr.rstrip(':')
_host = addr.compressed[len(_n):].lstrip(':')
_ob_host = _generate_address()
_ob_host = _generate_address(_host)
while _ob_host in self.hosts.values():
_ob_host = _generate_address()
_ob_host = _generate_address(_host)
self.add_obfuscated_host_address(addr.compressed, _ob_host)
return self.hosts[addr.compressed]

Expand Down
4 changes: 2 additions & 2 deletions sos/collector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,15 +1283,15 @@ def collect(self):
self.log_info(msg % (self.retrieved, self.report_num))
self.close_all_connections()
if self.retrieved > 0:
arc_name = self.create_cluster_archive()
self.arc_name = self.create_cluster_archive()
else:
msg = 'No sos reports were collected, nothing to archive...'
self.exit(msg, 1)

if (self.opts.upload and self.policy.get_upload_url()) or \
self.opts.upload_s3_endpoint:
try:
self.policy.upload_archive(arc_name)
self.policy.upload_archive(self.arc_name)
self.ui_log.info("Uploaded archive successfully")
except Exception as err:
self.ui_log.error(f"Upload attempt failed: {err}")
Expand Down
2 changes: 1 addition & 1 deletion sos/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def get_tmpdir_default(self):
def check_listing_options(self):
opts = [o for o in self.opts.dict().keys() if o.startswith('list')]
if opts:
return any([getattr(self.opts, opt) for opt in opts])
return any(getattr(self.opts, opt) for opt in opts)
return False

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion sos/policies/package_managers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def build_verify_command(self, packages):
verify_packages = ""
for package_list in verify_list:
for package in package_list:
if any([f in package for f in self.verify_filter]):
if any(f in package for f in self.verify_filter):
continue
if len(verify_packages):
verify_packages += " "
Expand Down
2 changes: 1 addition & 1 deletion sos/report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def _is_in_profile(self, plugin_class):
return False
if only_plugins and not self._is_not_specified(plugin_class.name()):
return True
return any([p in self.opts.profiles for p in plugin_class.profiles])
return any(p in self.opts.profiles for p in plugin_class.profiles)

def _is_skipped(self, plugin_name):
return plugin_name in self.opts.skip_plugins
Expand Down
7 changes: 4 additions & 3 deletions sos/report/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def set_value(self, val):
if type('') in self.val_type:
self.value = str(val)
return
if not any([type(val) is _t for _t in self.val_type]):
if not any(type(val) is _t for _t in self.val_type):
valid = []
for t in self.val_type:
if t is None:
Expand Down Expand Up @@ -1431,9 +1431,9 @@ def _is_forbidden_path(self, path):
)

def _is_policy_forbidden_path(self, path):
return any([
return any(
fnmatch.fnmatch(path, fp) for fp in self.policy.forbidden_paths
])
)

def _is_skipped_path(self, path):
"""Check if the given path matches a user-provided specification to
Expand Down Expand Up @@ -3521,6 +3521,7 @@ def filter_namespaces(self, ns_list, ns_pattern=None, ns_max=None):
namespaces (options originally present in the networking plugin.)
"""
out_ns = []
pattern = None

# Regex initialization outside of for loop
if ns_pattern:
Expand Down

0 comments on commit d3a2169

Please sign in to comment.