From a6f701802f0ac33e62dd36a01b5916b261ffba02 Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Fri, 1 Feb 2019 17:31:08 +0100 Subject: [PATCH] =?UTF-8?q?Simplify:=20set([GEN])=20=E2=86=92=20set(GEN)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/_version.py | 6 +++--- src/octoprint/access/users.py | 8 ++++---- src/octoprint/util/__init__.py | 2 +- src/octoprint/util/comm.py | 8 ++++---- versioneer.py | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/octoprint/_version.py b/src/octoprint/_version.py index 0c0628073..39183a6d6 100644 --- a/src/octoprint/_version.py +++ b/src/octoprint/_version.py @@ -158,11 +158,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): if verbose: print("keywords are unexpanded, not using") raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) + refs = set(r.strip() for r in refnames.strip("()").split(",")) # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of # just "foo-1.0". If we see a "tag: " prefix, prefer those. TAG = "tag: " - tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) + tags = set(r[len(TAG):] for r in refs if r.startswith(TAG)) if not tags: # Either we're using git < 1.8.3, or there really are no tags. We use # a heuristic: assume all version tags have a digit. The old git %d @@ -171,7 +171,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): # between branches and tags. By ignoring refnames without digits, we # filter out many common branch names like "release" and # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r'\d', r)]) + tags = set(r for r in refs if re.search(r'\d', r)) if verbose: print("discarding '%s', no digits" % ",".join(refs-tags)) diff --git a/src/octoprint/access/users.py b/src/octoprint/access/users.py index 8c0c4d89c..f4c94a8e2 100644 --- a/src/octoprint/access/users.py +++ b/src/octoprint/access/users.py @@ -772,17 +772,17 @@ class FilebasedUserManager(UserManager): def _to_groups(self, *groups): return list(set(filter(lambda x: x is not None, - [self._group_manager._to_group(group) for group in groups]))) + (self._group_manager._to_group(group) for group in groups)))) def _to_permissions(self, *permissions): return list(set(filter(lambda x: x is not None, - [Permissions.find(permission) for permission in permissions]))) + (Permissions.find(permission) for permission in permissions)))) def _from_groups(self, *groups): - return list(set([group.key for group in groups])) + return list(set(group.key for group in groups)) def _from_permissions(self, *permissions): - return list(set([permission.key for permission in permissions])) + return list(set(permission.key for permission in permissions)) # ~~ Deprecated methods follow diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index 25475a1a6..cd798d299 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -1681,7 +1681,7 @@ class CaseInsensitiveSet(collections.Set): """ def __init__(self, *args): - self.data = set([x.lower() if isinstance(x, past.builtins.basestring) else x for x in args]) + self.data = set(x.lower() if isinstance(x, past.builtins.basestring) else x for x in args) def __contains__(self, item): if isinstance(item, past.builtins.basestring): diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index a96668de7..f1cef60a4 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -256,23 +256,23 @@ class PositionRecord(object): return True def __init__(self, *args, **kwargs): - attrs = self._standard_attrs | set([key for key in kwargs if self.valid_e(key)]) + attrs = self._standard_attrs | set(key for key in kwargs if self.valid_e(key)) for attr in attrs: setattr(self, attr, kwargs.get(attr)) def copy_from(self, other): # make sure all standard attrs and attrs from other are set - attrs = self._standard_attrs | set([key for key in dir(other) if self.valid_e(key)]) + attrs = self._standard_attrs | set(key for key in dir(other) if self.valid_e(key)) for attr in attrs: setattr(self, attr, getattr(other, attr)) # delete attrs other doesn't have - attrs = set([key for key in dir(self) if self.valid_e(key)]) - attrs + attrs = set(key for key in dir(self) if self.valid_e(key)) - attrs for attr in attrs: delattr(self, attr) def as_dict(self): - attrs = self._standard_attrs | set([key for key in dir(self) if self.valid_e(key)]) + attrs = self._standard_attrs | set(key for key in dir(self) if self.valid_e(key)) return dict((attr, getattr(self, attr)) for attr in attrs) class TemperatureRecord(object): diff --git a/versioneer.py b/versioneer.py index e7dd18599..071a042dc 100644 --- a/versioneer.py +++ b/versioneer.py @@ -657,11 +657,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): if verbose: print("keywords are unexpanded, not using") raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) + refs = set(r.strip() for r in refnames.strip("()").split(",")) # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of # just "foo-1.0". If we see a "tag: " prefix, prefer those. TAG = "tag: " - tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) + tags = set(r[len(TAG):] for r in refs if r.startswith(TAG)) if not tags: # Either we're using git < 1.8.3, or there really are no tags. We use # a heuristic: assume all version tags have a digit. The old git %%d @@ -670,7 +670,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): # between branches and tags. By ignoring refnames without digits, we # filter out many common branch names like "release" and # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r'\d', r)]) + tags = set(r for r in refs if re.search(r'\d', r)) if verbose: print("discarding '%%s', no digits" %% ",".join(refs-tags)) @@ -1229,11 +1229,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): if verbose: print("keywords are unexpanded, not using") raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) + refs = set(r.strip() for r in refnames.strip("()").split(",")) # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of # just "foo-1.0". If we see a "tag: " prefix, prefer those. TAG = "tag: " - tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) + tags = set(r[len(TAG):] for r in refs if r.startswith(TAG)) if not tags: # Either we're using git < 1.8.3, or there really are no tags. We use # a heuristic: assume all version tags have a digit. The old git %d @@ -1242,7 +1242,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): # between branches and tags. By ignoring refnames without digits, we # filter out many common branch names like "release" and # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r'\d', r)]) + tags = set(r for r in refs if re.search(r'\d', r)) if verbose: print("discarding '%s', no digits" % ",".join(refs-tags))