diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 03526afe4c1..49ca9de6df5 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -47,7 +47,7 @@ jobs: - name: Check ALL Files On Branch if: github.event_name != 'pull_request' env: - SKIP: lint-salt,lint-tests,pyupgrade,remove-import-headers,rstcheck + SKIP: lint-salt,lint-tests,remove-import-headers,rstcheck run: | pre-commit run --show-diff-on-failure --color=always --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca007d7b421..0dca627f329 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1197,9 +1197,7 @@ repos: # ----- Code Formatting -------------------------------------------------------------------------------------------> - repo: https://github.com/asottile/pyupgrade - # This, for now, is meant to run when locally committing code and will be disabled(skipped) when we run pre-commit - # against all codebase to avoid MASSIVE code churn. This way, we do it in smaller chunks, a few at a time. - rev: v2.7.2 + rev: v2.31.0 hooks: - id: pyupgrade name: Drop six usage and Py2 support @@ -1207,7 +1205,7 @@ repos: exclude: > (?x)^( salt/client/ssh/ssh_py_shim.py| - salt/ext/ipaddress.py + salt/ext/.*\.py )$ - repo: https://github.com/saltstack/pre-commit-remove-import-headers diff --git a/doc/_ext/saltrepo.py b/doc/_ext/saltrepo.py index fd75ae21cee..0c1dafb4064 100644 --- a/doc/_ext/saltrepo.py +++ b/doc/_ext/saltrepo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ saltrepo ~~~~~~~~ diff --git a/doc/_ext/youtube.py b/doc/_ext/youtube.py index 35be8c1c78a..9603a326b7a 100644 --- a/doc/_ext/youtube.py +++ b/doc/_ext/youtube.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- # Taken from sphinx-contrib # https://bitbucket.org/birkenfeld/sphinx-contrib/src/a3d904f8ab24/youtube @@ -33,7 +32,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import division import re @@ -51,7 +49,7 @@ CONTROL_HEIGHT = 30 def get_size(d, key): if key not in d: return None - m = re.match("(\d+)(|%|px)$", d[key]) + m = re.match(r"(\d+)(|%|px)$", d[key]) if not m: raise ValueError("invalid size %r" % d[key]) return int(m.group(1)), m.group(2) or "px" @@ -134,7 +132,7 @@ class YouTube(Directive): def run(self): if "aspect" in self.options: aspect = self.options.get("aspect") - m = re.match("(\d+):(\d+)", aspect) + m = re.match(r"(\d+):(\d+)", aspect) if m is None: raise ValueError("invalid aspect ratio %r" % aspect) aspect = tuple(int(x) for x in m.groups()) diff --git a/salt/auth/__init__.py b/salt/auth/__init__.py index 2e9cff624cd..afd7ad65fa6 100644 --- a/salt/auth/__init__.py +++ b/salt/auth/__init__.py @@ -534,9 +534,7 @@ class Resolver: ) print( "Available eauth types: {}".format( - ", ".join( - sorted([k[:-5] for k in self.auth if k.endswith(".auth")]) - ) + ", ".join(sorted(k[:-5] for k in self.auth if k.endswith(".auth"))) ) ) return ret diff --git a/salt/beacons/twilio_txt_msg.py b/salt/beacons/twilio_txt_msg.py index 3010d0e980d..7ff5a361fb6 100644 --- a/salt/beacons/twilio_txt_msg.py +++ b/salt/beacons/twilio_txt_msg.py @@ -9,7 +9,7 @@ try: import twilio # Grab version, ensure elements are ints - twilio_version = tuple([int(x) for x in twilio.__version_info__]) + twilio_version = tuple(int(x) for x in twilio.__version_info__) if twilio_version > (5,): from twilio.rest import Client as TwilioRestClient else: diff --git a/salt/cloud/clouds/linode.py b/salt/cloud/clouds/linode.py index 7b90ed5de72..5d883cf938b 100644 --- a/salt/cloud/clouds/linode.py +++ b/salt/cloud/clouds/linode.py @@ -1813,10 +1813,8 @@ class LinodeAPIv3(LinodeAPI): vm_["name"], pprint.pprint( sorted( - [ - distro["LABEL"].encode(__salt_system_encoding__) - for distro in distributions - ] + distro["LABEL"].encode(__salt_system_encoding__) + for distro in distributions ) ), ) diff --git a/salt/cloud/libcloudfuncs.py b/salt/cloud/libcloudfuncs.py index dc569aac48e..ed67934b1c7 100644 --- a/salt/cloud/libcloudfuncs.py +++ b/salt/cloud/libcloudfuncs.py @@ -22,12 +22,10 @@ try: HAS_LIBCLOUD = True LIBCLOUD_VERSION_INFO = tuple( - [ - int(part) - for part in libcloud.__version__.replace("-", ".") - .replace("rc", ".") - .split(".")[:3] - ] + int(part) + for part in libcloud.__version__.replace("-", ".") + .replace("rc", ".") + .split(".")[:3] ) except ImportError: diff --git a/salt/grains/core.py b/salt/grains/core.py index bdfaa8b0504..9b2f9298ab8 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -1775,15 +1775,15 @@ def _parse_cpe_name(cpe): ret["phase"] = cpe[5] if len(cpe) > 5 else None ret["part"] = part.get(cpe[1][1:]) elif len(cpe) == 6 and cpe[1] == "2.3": # WFN to a string - ret["vendor"], ret["product"], ret["version"] = [ + ret["vendor"], ret["product"], ret["version"] = ( x if x != "*" else None for x in cpe[3:6] - ] + ) ret["phase"] = None ret["part"] = part.get(cpe[2]) elif len(cpe) > 7 and len(cpe) <= 13 and cpe[1] == "2.3": # WFN to a string - ret["vendor"], ret["product"], ret["version"], ret["phase"] = [ + ret["vendor"], ret["product"], ret["version"], ret["phase"] = ( x if x != "*" else None for x in cpe[3:7] - ] + ) ret["part"] = part.get(cpe[2]) return ret @@ -2103,9 +2103,9 @@ def os_data(): log.trace( "Getting OS name, release, and codename from distro id, version, codename" ) - (osname, osrelease, oscodename) = [ + (osname, osrelease, oscodename) = ( x.strip('"').strip("'") for x in _linux_distribution() - ] + ) # Try to assign these three names based on the lsb info, they tend to # be more accurate than what python gets from /etc/DISTRO-release. # It's worth noting that Ubuntu has patched their Python distribution diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py index 7ded2944c66..f32548ae3b6 100644 --- a/salt/modules/aptpkg.py +++ b/salt/modules/aptpkg.py @@ -1472,9 +1472,9 @@ def list_pkgs( for line in out.splitlines(): cols = line.split() try: - linetype, status, name, version_num, arch = [ + linetype, status, name, version_num, arch = ( cols[x] for x in (0, 2, 3, 4, 5) - ] + ) except (ValueError, IndexError): continue if __grains__.get("cpuarch", "") == "x86_64": @@ -2997,7 +2997,7 @@ def show(*names, **kwargs): line = line.strip() if line: try: - key, val = [x.strip() for x in line.split(":", 1)] + key, val = (x.strip() for x in line.split(":", 1)) except ValueError: pass else: diff --git a/salt/modules/bcache.py b/salt/modules/bcache.py index e3a7144a2fb..b3c1a92559b 100644 --- a/salt/modules/bcache.py +++ b/salt/modules/bcache.py @@ -644,13 +644,13 @@ def super_(dev): if not line: continue - key, val = [val.strip() for val in re.split(r"[\s]+", line, maxsplit=1)] + key, val = (val.strip() for val in re.split(r"[\s]+", line, maxsplit=1)) if not (key and val): continue mval = None if " " in val: - rval, mval = [val.strip() for val in re.split(r"[\s]+", val, maxsplit=1)] + rval, mval = (val.strip() for val in re.split(r"[\s]+", val, maxsplit=1)) mval = mval[1:-1] else: rval = val diff --git a/salt/modules/boto_asg.py b/salt/modules/boto_asg.py index 08df7b7197a..7bdad75c7a0 100644 --- a/salt/modules/boto_asg.py +++ b/salt/modules/boto_asg.py @@ -188,7 +188,7 @@ def get_config(name, region=None, key=None, keyid=None, profile=None): # convert SuspendedProcess objects to names elif attr == "suspended_processes": suspended_processes = getattr(asg, attr) - ret[attr] = sorted([x.process_name for x in suspended_processes]) + ret[attr] = sorted(x.process_name for x in suspended_processes) else: ret[attr] = getattr(asg, attr) # scaling policies diff --git a/salt/modules/boto_ec2.py b/salt/modules/boto_ec2.py index ec87c8a4e77..73281ab4249 100644 --- a/salt/modules/boto_ec2.py +++ b/salt/modules/boto_ec2.py @@ -232,9 +232,9 @@ def get_eip_address_info( .. versionadded:: 2016.3.0 """ - if type(addresses) == (type("string")): + if isinstance(addresses, str): addresses = [addresses] - if type(allocation_ids) == (type("string")): + if isinstance(allocation_ids, str): allocation_ids = [allocation_ids] ret = _get_all_eip_addresses( diff --git a/salt/modules/btrfs.py b/salt/modules/btrfs.py index 606419c2a73..4a1d37fbfcb 100644 --- a/salt/modules/btrfs.py +++ b/salt/modules/btrfs.py @@ -58,7 +58,7 @@ def _parse_btrfs_info(data): for line in [line for line in data.split("\n") if line][:-1]: if line.startswith("Label:"): line = re.sub(r"Label:\s+", "", line) - label, uuid_ = [tkn.strip() for tkn in line.split("uuid:")] + label, uuid_ = (tkn.strip() for tkn in line.split("uuid:")) ret["label"] = label != "none" and label or None ret["uuid"] = uuid_ continue diff --git a/salt/modules/dockercompose.py b/salt/modules/dockercompose.py index f47100b7b48..a785b983c62 100644 --- a/salt/modules/dockercompose.py +++ b/salt/modules/dockercompose.py @@ -145,7 +145,7 @@ def __virtual__(): if HAS_DOCKERCOMPOSE: match = re.match(VERSION_RE, str(compose.__version__)) if match: - version = tuple([int(x) for x in match.group(1).split(".")]) + version = tuple(int(x) for x in match.group(1).split(".")) if version >= MIN_DOCKERCOMPOSE: return __virtualname__ return ( diff --git a/salt/modules/dockermod.py b/salt/modules/dockermod.py index db0233795f3..199f10f2773 100644 --- a/salt/modules/dockermod.py +++ b/salt/modules/dockermod.py @@ -2505,11 +2505,11 @@ def version(): if "Version" in ret: match = version_re.match(str(ret["Version"])) if match: - ret["VersionInfo"] = tuple([int(x) for x in match.group(1).split(".")]) + ret["VersionInfo"] = tuple(int(x) for x in match.group(1).split(".")) if "ApiVersion" in ret: match = version_re.match(str(ret["ApiVersion"])) if match: - ret["ApiVersionInfo"] = tuple([int(x) for x in match.group(1).split(".")]) + ret["ApiVersionInfo"] = tuple(int(x) for x in match.group(1).split(".")) return ret diff --git a/salt/modules/file.py b/salt/modules/file.py index d62c38f99cd..6673e4fca8b 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -874,9 +874,9 @@ def get_source_sum( # The source_hash is a hash expression ret = {} try: - ret["hash_type"], ret["hsum"] = [ + ret["hash_type"], ret["hsum"] = ( x.strip() for x in source_hash.split("=", 1) - ] + ) except AttributeError: _invalid_source_hash_format() except ValueError: diff --git a/salt/modules/inspectlib/query.py b/salt/modules/inspectlib/query.py index 079cc291725..bd01e67ba7a 100644 --- a/salt/modules/inspectlib/query.py +++ b/salt/modules/inspectlib/query.py @@ -53,9 +53,9 @@ class SysInfo: log.error(msg) raise SIException(msg) - devpath, blocks, used, available, used_p, mountpoint = [ + devpath, blocks, used, available, used_p, mountpoint = ( elm for elm in out["stdout"].split(os.linesep)[-1].split(" ") if elm - ] + ) return { "device": devpath, "blocks": blocks, diff --git a/salt/modules/kernelpkg_linux_apt.py b/salt/modules/kernelpkg_linux_apt.py index feb8045cb4a..2534565d568 100644 --- a/salt/modules/kernelpkg_linux_apt.py +++ b/salt/modules/kernelpkg_linux_apt.py @@ -74,7 +74,7 @@ def list_installed(): prefix_len = len(_package_prefix()) + 1 return sorted( - [pkg[prefix_len:] for pkg in result], key=functools.cmp_to_key(_cmp_version) + (pkg[prefix_len:] for pkg in result), key=functools.cmp_to_key(_cmp_version) ) diff --git a/salt/modules/linux_shadow.py b/salt/modules/linux_shadow.py index e9e5483ef19..01de86b2f87 100644 --- a/salt/modules/linux_shadow.py +++ b/salt/modules/linux_shadow.py @@ -519,10 +519,7 @@ def list_users(root=None): getspall = functools.partial(spwd.getspall) return sorted( - [ - user.sp_namp if hasattr(user, "sp_namp") else user.sp_nam - for user in getspall() - ] + user.sp_namp if hasattr(user, "sp_namp") else user.sp_nam for user in getspall() ) diff --git a/salt/modules/lxc.py b/salt/modules/lxc.py index 9710f83262b..28d602dd784 100644 --- a/salt/modules/lxc.py +++ b/salt/modules/lxc.py @@ -983,7 +983,7 @@ def _get_veths(net_data): if sitem.startswith("#") or not sitem: continue elif "=" in item: - item = tuple([a.strip() for a in item.split("=", 1)]) + item = tuple(a.strip() for a in item.split("=", 1)) if item[0] == "lxc.network.type": current_nic = salt.utils.odict.OrderedDict() if item[0] == "lxc.network.name": diff --git a/salt/modules/pacmanpkg.py b/salt/modules/pacmanpkg.py index 27fedea394c..a03be2901cb 100644 --- a/salt/modules/pacmanpkg.py +++ b/salt/modules/pacmanpkg.py @@ -1036,7 +1036,7 @@ def list_repo_pkgs(*args, **kwargs): # Sort versions newest to oldest for pkgname in ret[reponame]: sorted_versions = sorted( - [_LooseVersion(x) for x in ret[reponame][pkgname]], reverse=True + (_LooseVersion(x) for x in ret[reponame][pkgname]), reverse=True ) ret[reponame][pkgname] = [x.vstring for x in sorted_versions] return ret @@ -1047,7 +1047,7 @@ def list_repo_pkgs(*args, **kwargs): byrepo_ret.setdefault(pkgname, []).extend(ret[reponame][pkgname]) for pkgname in byrepo_ret: sorted_versions = sorted( - [_LooseVersion(x) for x in byrepo_ret[pkgname]], reverse=True + (_LooseVersion(x) for x in byrepo_ret[pkgname]), reverse=True ) byrepo_ret[pkgname] = [x.vstring for x in sorted_versions] return byrepo_ret diff --git a/salt/modules/pkgin.py b/salt/modules/pkgin.py index 4319ffd96d6..c27b6ed8fce 100644 --- a/salt/modules/pkgin.py +++ b/salt/modules/pkgin.py @@ -72,7 +72,7 @@ def _supports_regex(): """ Check support of regexp """ - return tuple([int(i) for i in _get_version()]) > (0, 5) + return tuple(int(i) for i in _get_version()) > (0, 5) @decorators.memoize @@ -80,7 +80,7 @@ def _supports_parsing(): """ Check support of parsing """ - return tuple([int(i) for i in _get_version()]) > (0, 6) + return tuple(int(i) for i in _get_version()) > (0, 6) def __virtual__(): diff --git a/salt/modules/pw_user.py b/salt/modules/pw_user.py index 3e786e931e3..6506452db56 100644 --- a/salt/modules/pw_user.py +++ b/salt/modules/pw_user.py @@ -503,7 +503,7 @@ def list_users(): salt '*' user.list_users """ - return sorted([user.pw_name for user in pwd.getpwall()]) + return sorted(user.pw_name for user in pwd.getpwall()) def rename(name, new_name): diff --git a/salt/modules/rh_ip.py b/salt/modules/rh_ip.py index 4eddf9ac5d1..44202b390ea 100644 --- a/salt/modules/rh_ip.py +++ b/salt/modules/rh_ip.py @@ -712,7 +712,7 @@ def _parse_settings_eth(opts, iface_type, enabled, iface): result["ipaddrs"] = [] for opt in opts["ipaddrs"]: if salt.utils.validate.net.ipv4_addr(opt): - ip, prefix = [i.strip() for i in opt.split("/")] + ip, prefix = (i.strip() for i in opt.split("/")) result["ipaddrs"].append({"ipaddr": ip, "prefix": prefix}) else: msg = "ipv4 CIDR is invalid" diff --git a/salt/modules/runit.py b/salt/modules/runit.py index 404570ff946..333c4ffd67b 100644 --- a/salt/modules/runit.py +++ b/salt/modules/runit.py @@ -383,7 +383,7 @@ def _get_svc_list(name="*", status=None): 'DISABLED' : available service that is not enabled 'ENABLED' : enabled service (whether started on boot or not) """ - return sorted([os.path.basename(el) for el in _get_svc_path(name, status)]) + return sorted(os.path.basename(el) for el in _get_svc_path(name, status)) def get_svc_alias(): diff --git a/salt/modules/solaris_user.py b/salt/modules/solaris_user.py index b6911ff60db..e8d7d0b2bc4 100644 --- a/salt/modules/solaris_user.py +++ b/salt/modules/solaris_user.py @@ -443,7 +443,7 @@ def list_users(): salt '*' user.list_users """ - return sorted([user.pw_name for user in pwd.getpwall()]) + return sorted(user.pw_name for user in pwd.getpwall()) def rename(name, new_name): diff --git a/salt/modules/splunk_search.py b/salt/modules/splunk_search.py index b8f6e115e88..58a64b2dc1d 100644 --- a/salt/modules/splunk_search.py +++ b/salt/modules/splunk_search.py @@ -270,7 +270,7 @@ def list_all( results = OrderedDict() # sort the splunk searches by name, so we get consistent output - searches = sorted([(s.name, s) for s in client.saved_searches]) + searches = sorted((s.name, s) for s in client.saved_searches) for name, search in searches: if app and search.access.app != app: continue diff --git a/salt/modules/twilio_notify.py b/salt/modules/twilio_notify.py index dc290718294..5d28e7922fa 100644 --- a/salt/modules/twilio_notify.py +++ b/salt/modules/twilio_notify.py @@ -26,7 +26,7 @@ try: import twilio # Grab version, ensure elements are ints - twilio_version = tuple([int(x) for x in twilio.__version_info__]) + twilio_version = tuple(int(x) for x in twilio.__version_info__) if twilio_version > (5,): TWILIO_5 = False from twilio.rest import Client as TwilioRestClient diff --git a/salt/modules/useradd.py b/salt/modules/useradd.py index 211e83ac1c9..00362ebfc3c 100644 --- a/salt/modules/useradd.py +++ b/salt/modules/useradd.py @@ -874,7 +874,7 @@ def list_users(root=None): else: getpwall = functools.partial(pwd.getpwall) - return sorted([user.pw_name for user in getpwall()]) + return sorted(user.pw_name for user in getpwall()) def rename(name, new_name, root=None): diff --git a/salt/modules/virt.py b/salt/modules/virt.py index 0e40f94f776..a5aa919adb7 100644 --- a/salt/modules/virt.py +++ b/salt/modules/virt.py @@ -1780,11 +1780,7 @@ def _fill_disk_filename(conn, vm_name, disk, hypervisor, pool_caps): int(re.sub("[a-z]+", "", vol_name)) for vol_name in all_volumes ] or [0] index = min( - [ - idx - for idx in range(1, max(indexes) + 2) - if idx not in indexes - ] + idx for idx in range(1, max(indexes) + 2) if idx not in indexes ) disk["filename"] = "{}{}".format(os.path.basename(device), index) diff --git a/salt/modules/virtualenv_mod.py b/salt/modules/virtualenv_mod.py index 726057d75cf..a94a22b00eb 100644 --- a/salt/modules/virtualenv_mod.py +++ b/salt/modules/virtualenv_mod.py @@ -67,7 +67,7 @@ def virtualenv_ver(venv_bin, user=None, **kwargs): [x for x in ret["stdout"].strip().split() if re.search(r"^\d.\d*", x)] ) virtualenv_version_info = tuple( - [int(i) for i in re.sub(r"(rc|\+ds).*$", "", version).split(".")] + int(i) for i in re.sub(r"(rc|\+ds).*$", "", version).split(".") ) return virtualenv_version_info diff --git a/salt/modules/win_iis.py b/salt/modules/win_iis.py index 8c1bbf10853..f555062681c 100644 --- a/salt/modules/win_iis.py +++ b/salt/modules/win_iis.py @@ -247,7 +247,7 @@ def list_sites(): filtered_binding.update({key.lower(): binding[key]}) binding_info = binding["bindingInformation"].split(":", 2) - ipaddress, port, hostheader = [element.strip() for element in binding_info] + ipaddress, port, hostheader = (element.strip() for element in binding_info) filtered_binding.update( {"hostheader": hostheader, "ipaddress": ipaddress, "port": port} ) diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index a0e8a39659b..c85c1d46e3a 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -1316,7 +1316,7 @@ def _get_source_sum(source_hash, file_path, saltenv): ) raise SaltInvocationError(invalid_hash_msg) - ret["hash_type"], ret["hsum"] = [item.strip().lower() for item in items] + ret["hash_type"], ret["hsum"] = (item.strip().lower() for item in items) return ret diff --git a/salt/modules/xfs.py b/salt/modules/xfs.py index a82496cd85b..60329c9a13a 100644 --- a/salt/modules/xfs.py +++ b/salt/modules/xfs.py @@ -288,7 +288,7 @@ def _xfs_prune_output(out, uuid): cnt.append(line) for kset in [e for e in cnt[1:] if ":" in e]: - key, val = [t.strip() for t in kset.split(":", 1)] + key, val = (t.strip() for t in kset.split(":", 1)) data[key.lower().replace(" ", "_")] = val return data.get("uuid") == uuid and data or {} diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index cf684e20f73..b977efdbd05 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -1010,7 +1010,7 @@ def list_repo_pkgs(*args, **kwargs): # Sort versions newest to oldest for pkgname in ret[reponame]: sorted_versions = sorted( - [_LooseVersion(x) for x in ret[reponame][pkgname]], reverse=True + (_LooseVersion(x) for x in ret[reponame][pkgname]), reverse=True ) ret[reponame][pkgname] = [x.vstring for x in sorted_versions] return ret @@ -1021,7 +1021,7 @@ def list_repo_pkgs(*args, **kwargs): byrepo_ret.setdefault(pkgname, []).extend(ret[reponame][pkgname]) for pkgname in byrepo_ret: sorted_versions = sorted( - [_LooseVersion(x) for x in byrepo_ret[pkgname]], reverse=True + (_LooseVersion(x) for x in byrepo_ret[pkgname]), reverse=True ) byrepo_ret[pkgname] = [x.vstring for x in sorted_versions] return byrepo_ret @@ -2566,7 +2566,7 @@ def group_info(name, expand=False, ignore_groups=None): g_info = {} for line in salt.utils.itertools.split(out, "\n"): try: - key, value = [x.strip() for x in line.split(":")] + key, value = (x.strip() for x in line.split(":")) g_info[key.lower()] = value except ValueError: continue diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py index 13f5487a86d..504d87e7dc0 100644 --- a/salt/modules/zypperpkg.py +++ b/salt/modules/zypperpkg.py @@ -435,10 +435,8 @@ class Wildcard: self.name = pkg_name self._set_version(pkg_version) # Dissects possible operator versions = sorted( - [ - LooseVersion(vrs) - for vrs in self._get_scope_versions(self._get_available_versions()) - ] + LooseVersion(vrs) + for vrs in self._get_scope_versions(self._get_available_versions()) ) return versions and "{}{}".format(self._op or "", versions[-1]) or None @@ -1080,7 +1078,7 @@ def list_repo_pkgs(*args, **kwargs): # Sort versions newest to oldest for pkgname in ret[reponame]: sorted_versions = sorted( - [LooseVersion(x) for x in ret[reponame][pkgname]], reverse=True + (LooseVersion(x) for x in ret[reponame][pkgname]), reverse=True ) ret[reponame][pkgname] = [x.vstring for x in sorted_versions] return ret @@ -1091,7 +1089,7 @@ def list_repo_pkgs(*args, **kwargs): byrepo_ret.setdefault(pkgname, []).extend(ret[reponame][pkgname]) for pkgname in byrepo_ret: sorted_versions = sorted( - [LooseVersion(x) for x in byrepo_ret[pkgname]], reverse=True + (LooseVersion(x) for x in byrepo_ret[pkgname]), reverse=True ) byrepo_ret[pkgname] = [x.vstring for x in sorted_versions] return byrepo_ret @@ -2047,7 +2045,7 @@ def list_locks(root=None): for element in [el for el in meta if el]: if ":" in element: lock.update( - dict([tuple([i.strip() for i in element.split(":", 1)])]) + dict([tuple(i.strip() for i in element.split(":", 1))]) ) if lock.get("solvable_name"): locks[lock.pop("solvable_name")] = lock diff --git a/salt/output/table_out.py b/salt/output/table_out.py index 133d094c4c0..730e0cb2df8 100644 --- a/salt/output/table_out.py +++ b/salt/output/table_out.py @@ -155,7 +155,7 @@ class TableDisplay: columns = map(lambda *args: args, *reduce(operator.add, logical_rows)) - max_widths = [max([len(str(item)) for item in column]) for column in columns] + max_widths = [max(len(str(item)) for item in column) for column in columns] row_separator = self.row_delimiter * ( len(self.prefix) + len(self.suffix) diff --git a/salt/returners/sentry_return.py b/salt/returners/sentry_return.py index 97221d635a1..0b660392ef0 100644 --- a/salt/returners/sentry_return.py +++ b/salt/returners/sentry_return.py @@ -112,11 +112,9 @@ def _get_message(ret): if isinstance(kwargs, dict): kwarg_string = " ".join( sorted( - [ - "{}={}".format(k, v) - for k, v in kwargs.items() - if not k.startswith("_") - ] + "{}={}".format(k, v) + for k, v in kwargs.items() + if not k.startswith("_") ) ) return "salt func: {fun} {argstr} {kwargstr}".format( diff --git a/salt/returners/sms_return.py b/salt/returners/sms_return.py index c9008b81316..883a6a7eae4 100644 --- a/salt/returners/sms_return.py +++ b/salt/returners/sms_return.py @@ -37,7 +37,7 @@ try: import twilio # Grab version, ensure elements are ints - twilio_version = tuple([int(x) for x in twilio.__version_info__]) + twilio_version = tuple(int(x) for x in twilio.__version_info__) if twilio_version > (5,): TWILIO_5 = False from twilio.rest import Client as TwilioRestClient diff --git a/salt/roster/cache.py b/salt/roster/cache.py index 694f8c48a5e..a6a117d2d8e 100644 --- a/salt/roster/cache.py +++ b/salt/roster/cache.py @@ -173,8 +173,8 @@ def _load_minion(minion_id, cache): pillar = {} addrs = { - 4: sorted([ipaddress.IPv4Address(addr) for addr in grains.get("ipv4", [])]), - 6: sorted([ipaddress.IPv6Address(addr) for addr in grains.get("ipv6", [])]), + 4: sorted(ipaddress.IPv4Address(addr) for addr in grains.get("ipv4", [])), + 6: sorted(ipaddress.IPv6Address(addr) for addr in grains.get("ipv6", [])), } mine = cache.fetch("minions/{}".format(minion_id), "mine") diff --git a/salt/runners/manage.py b/salt/runners/manage.py index acc9653af4c..a4786106594 100644 --- a/salt/runners/manage.py +++ b/salt/runners/manage.py @@ -797,10 +797,10 @@ def bootstrap_psexec( '>(Salt-Minion-(.+?)-(.+)-Setup.exe)