Signed-off-by: Aaron Bauman <b...@gentoo.org> --- lib/_emerge/actions.py | 14 +++++++------- lib/_emerge/resolver/slot_collision.py | 4 ++-- lib/_emerge/stdout_spinner.py | 2 +- lib/_emerge/unmerge.py | 4 ++-- lib/portage/_sets/dbapi.py | 6 +++--- lib/portage/cache/template.py | 2 +- lib/portage/dep/__init__.py | 10 +++++----- lib/portage/dep/dep_check.py | 2 +- lib/portage/getbinpkg.py | 6 +++--- lib/portage/glsa.py | 2 +- lib/portage/localization.py | 2 +- lib/portage/locks.py | 2 +- lib/portage/manifest.py | 2 +- lib/portage/news.py | 4 ++-- lib/portage/package/ebuild/config.py | 2 +- lib/portage/process.py | 6 +++--- lib/portage/sync/controller.py | 4 ++-- lib/portage/sync/modules/rsync/rsync.py | 8 ++++---- lib/portage/tests/resolver/ResolverPlayground.py | 2 +- lib/portage/util/__init__.py | 4 ++-- lib/portage/util/env_update.py | 2 +- lib/portage/xpak.py | 10 +++++----- pylintrc | 1 + 23 files changed, 51 insertions(+), 50 deletions(-)
diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py index 43e9de43a..7d2d9b315 100644 --- a/lib/_emerge/actions.py +++ b/lib/_emerge/actions.py @@ -333,7 +333,7 @@ def action_build(emerge_config, trees=DeprecationWarning, return 1 else: - if ("--resume" in myopts): + if "--resume" in myopts: print(darkgreen("emerge: It seems we have nothing to resume...")) return os.EX_OK @@ -450,7 +450,7 @@ def action_build(emerge_config, trees=DeprecationWarning, myopts.pop("--ask", None) if ("--pretend" in myopts) and not ("--fetchonly" in myopts or "--fetch-all-uri" in myopts): - if ("--resume" in myopts): + if "--resume" in myopts: mymergelist = mydepgraph.altlist() if len(mymergelist) == 0: print(colorize("INFORM", "emerge: It seems we have nothing to resume...")) @@ -522,7 +522,7 @@ def action_build(emerge_config, trees=DeprecationWarning, level=logging.ERROR, noiselevel=-1) return 1 - if ("--resume" in myopts): + if "--resume" in myopts: favorites=mtimedb["resume"]["favorites"] else: @@ -2319,7 +2319,7 @@ def adjust_config(myopts, settings): settings.backup_changes("PORTAGE_VERBOSE") # Set so that configs will be merged regardless of remembered status - if ("--noconfmem" in myopts): + if "--noconfmem" in myopts: settings["NOCONFMEM"]="1" settings.backup_changes("NOCONFMEM") @@ -2424,7 +2424,7 @@ def getportageversion(portdir, _unused, profile, chost, vardb): if profilever is None: try: profilever = "!" + os.readlink(profile) - except (OSError): + except OSError: pass if profilever is None: @@ -3057,7 +3057,7 @@ def run_action(emerge_config): level=logging.ERROR, noiselevel=-1) return 1 - if ("--quiet" in emerge_config.opts): + if "--quiet" in emerge_config.opts: spinner.update = spinner.update_quiet portage.util.noiselimit = -1 @@ -3085,7 +3085,7 @@ def run_action(emerge_config): if "python-trace" in emerge_config.target_config.settings.features: portage.debug.set_trace(True) - if not ("--quiet" in emerge_config.opts): + if not "--quiet" in emerge_config.opts: if '--nospinner' in emerge_config.opts or \ emerge_config.target_config.settings.get('TERM') == 'dumb' or \ not sys.stdout.isatty(): diff --git a/lib/_emerge/resolver/slot_collision.py b/lib/_emerge/resolver/slot_collision.py index 7536ce7a2..df3816717 100644 --- a/lib/_emerge/resolver/slot_collision.py +++ b/lib/_emerge/resolver/slot_collision.py @@ -138,8 +138,8 @@ class slot_conflict_handler: config_gen = _configuration_generator(conflict_pkgs) first_config = True - #go through all configurations and collect solutions - while(True): + # Go through all configurations and collect solutions + while True: config = config_gen.get_configuration() if not config: break diff --git a/lib/_emerge/stdout_spinner.py b/lib/_emerge/stdout_spinner.py index 26592b7b0..70e132683 100644 --- a/lib/_emerge/stdout_spinner.py +++ b/lib/_emerge/stdout_spinner.py @@ -65,7 +65,7 @@ class stdout_spinner: def update_scroll(self): if self._return_early(): return True - if(self.spinpos >= len(self.scroll_sequence)): + if self.spinpos >= len(self.scroll_sequence): sys.stdout.write(darkgreen(" \b\b\b" + self.scroll_sequence[ len(self.scroll_sequence) - 1 - (self.spinpos % len(self.scroll_sequence))])) else: diff --git a/lib/_emerge/unmerge.py b/lib/_emerge/unmerge.py index 5204ac6f0..548edaf0c 100644 --- a/lib/_emerge/unmerge.py +++ b/lib/_emerge/unmerge.py @@ -168,7 +168,7 @@ def _unmerge_display(root_config, myopts, unmerge_action, "="+"/".join(sp_absx[sp_vdb_len:])) newline="" - if (not "--quiet" in myopts): + if not "--quiet" in myopts: newline="\n" if settings["ROOT"] != "/": writemsg_level(darkgreen(newline+ \ @@ -176,7 +176,7 @@ def _unmerge_display(root_config, myopts, unmerge_action, settings["ROOT"])) if (("--pretend" in myopts) or ("--ask" in myopts)) and \ - not ("--quiet" in myopts): + not "--quiet" in myopts: writemsg_level(darkgreen(newline+\ ">>> These are the packages that would be unmerged:\n")) diff --git a/lib/portage/_sets/dbapi.py b/lib/portage/_sets/dbapi.py index 15d1c3786..288e4e75b 100644 --- a/lib/portage/_sets/dbapi.py +++ b/lib/portage/_sets/dbapi.py @@ -418,7 +418,7 @@ class DateSet(EverythingSet): setformat = formats[0] - if (setformat == "package"): + if setformat == "package": package = options.get("package") try: cpv = vardbapi.match(package)[0] @@ -426,13 +426,13 @@ class DateSet(EverythingSet): date = int(date) except (KeyError, ValueError): raise SetConfigError(_("cannot determine installation date of package %s") % package) - elif (setformat == "filestamp"): + elif setformat == "filestamp": filestamp = options.get("filestamp") try: date = int(os.stat(filestamp).st_mtime) except (OSError, ValueError): raise SetConfigError(_("cannot determine 'filestamp' of '%s'") % filestamp) - elif (setformat == "seconds"): + elif setformat == "seconds": try: date = int(options.get("seconds")) except ValueError: diff --git a/lib/portage/cache/template.py b/lib/portage/cache/template.py index c8351a924..31a4acc44 100644 --- a/lib/portage/cache/template.py +++ b/lib/portage/cache/template.py @@ -179,7 +179,7 @@ class database: def sync(self, rate=0): self.sync_rate = rate - if(rate == 0): + if rate == 0: self.commit() def commit(self): diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py index 50266a21b..7b63446cb 100644 --- a/lib/portage/dep/__init__.py +++ b/lib/portage/dep/__init__.py @@ -1901,7 +1901,7 @@ def dep_getusedeps( depend ): # -1 = failure (think c++ string::npos) comma_separated = False bracket_count = 0 - while( open_bracket != -1 ): + while open_bracket != -1: bracket_count += 1 if bracket_count > 1: raise InvalidAtom(_("USE Dependency with more " @@ -2610,13 +2610,13 @@ def check_required_use(required_use, use, iuse_match, eapi=None): return True if operator == "||": - return (True in argument) + return True in argument if operator == "^^": - return (argument.count(True) == 1) + return argument.count(True) == 1 if operator == "??": - return (argument.count(True) <= 1) + return argument.count(True) <= 1 if operator[-1] == "?": - return (False not in argument) + return False not in argument mysplit = required_use.split() level = 0 diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py index b6491a430..60c8ec6d0 100644 --- a/lib/portage/dep/dep_check.py +++ b/lib/portage/dep/dep_check.py @@ -736,7 +736,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None, if choice.all_available or allow_masked: return choice.atoms - assert(False) # This point should not be reachable + assert False # This point should not be reachable def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None, use_cache=1, use_binaries=0, myroot=None, trees=None): diff --git a/lib/portage/getbinpkg.py b/lib/portage/getbinpkg.py index d588b324b..0384986d1 100644 --- a/lib/portage/getbinpkg.py +++ b/lib/portage/getbinpkg.py @@ -180,7 +180,7 @@ def create_conn(baseurl, conn=None): conn = http_client_HTTPConnection(host) elif protocol == "ftp": passive = 1 - if(host[-1] == "*"): + if host[-1] == "*": passive = 0 host = host[:-1] conn = ftplib.FTP(host) @@ -287,10 +287,10 @@ def make_http_request(conn, address, _params={}, headers={}, dest=None): for x in str(response.msg).split("\n"): parts = x.split(": ", 1) if parts[0] == "Location": - if (rc == 301): + if rc == 301: sys.stderr.write(colorize("BAD", _("Location has moved: ")) + str(parts[1]) + "\n") - if (rc == 302): + if rc == 302: sys.stderr.write(colorize("BAD", _("Location has temporarily moved: ")) + \ str(parts[1]) + "\n") diff --git a/lib/portage/glsa.py b/lib/portage/glsa.py index 12b33f45d..27957180b 100644 --- a/lib/portage/glsa.py +++ b/lib/portage/glsa.py @@ -666,7 +666,7 @@ class Glsa: if not os.access(os.path.join(self.config["EROOT"], PRIVATE_PATH, "glsa_injected"), os.R_OK): return False - return (self.nr in get_applied_glsas(self.config)) + return self.nr in get_applied_glsas(self.config) def inject(self): """ diff --git a/lib/portage/localization.py b/lib/portage/localization.py index b215b9cba..de54295a2 100644 --- a/lib/portage/localization.py +++ b/lib/portage/localization.py @@ -43,4 +43,4 @@ def localized_size(num_bytes): except UnicodeDecodeError: # failure to decode locale data formatted_num = str(num_kib) - return (_unicode_decode(formatted_num, encoding=_encodings['stdio']) + ' KiB') + return _unicode_decode(formatted_num, encoding=_encodings['stdio']) + ' KiB' diff --git a/lib/portage/locks.py b/lib/portage/locks.py index 5fa6d5d38..701093024 100644 --- a/lib/portage/locks.py +++ b/lib/portage/locks.py @@ -441,7 +441,7 @@ def unlockfile(mytuple): else: raise InvalidData - if(myfd == HARDLINK_FD): + if myfd == HARDLINK_FD: unhardlink_lockfile(lockfilename, unlinkfile=unlinkfile) return True diff --git a/lib/portage/manifest.py b/lib/portage/manifest.py index d43f7d836..51a93b35e 100644 --- a/lib/portage/manifest.py +++ b/lib/portage/manifest.py @@ -421,7 +421,7 @@ class Manifest: def hasFile(self, ftype, fname): """ Return whether the Manifest contains an entry for the given type,filename pair """ - return (fname in self.fhashdict[ftype]) + return fname in self.fhashdict[ftype] def findFile(self, fname): """ Return entrytype of the given file if present in Manifest or None if not present """ diff --git a/lib/portage/news.py b/lib/portage/news.py index 21a7c6a1f..3d6b04e1e 100644 --- a/lib/portage/news.py +++ b/lib/portage/news.py @@ -346,8 +346,8 @@ class DisplayProfileRestriction(DisplayRestriction): def checkRestriction(self, **kwargs): if fnmatch.fnmatch(self.format, '2.*') and self.profile.endswith('/*'): - return (kwargs['profile'].startswith(self.profile[:-1])) - return (kwargs['profile'] == self.profile) + return kwargs['profile'].startswith(self.profile[:-1]) + return kwargs['profile'] == self.profile class DisplayKeywordRestriction(DisplayRestriction): """ diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py index 74b998d0b..b62ad3069 100644 --- a/lib/portage/package/ebuild/config.py +++ b/lib/portage/package/ebuild/config.py @@ -2344,7 +2344,7 @@ class config: if not x: continue - if (x[0]=="-"): + if x[0] == "-": myflags.discard(x[1:]) continue diff --git a/lib/portage/process.py b/lib/portage/process.py index 1ff886bf3..8d4cf164e 100644 --- a/lib/portage/process.py +++ b/lib/portage/process.py @@ -433,11 +433,11 @@ def spawn(mycommand, env=None, opt_name=None, fd_pipes=None, returnpid=False, os.waitpid(pid, 0) # If it got a signal, return the signal that was sent. - if (retval & 0xff): - return ((retval & 0xff) << 8) + if retval & 0xff: + return (retval & 0xff) << 8 # Otherwise, return its exit code. - return (retval >> 8) + return retval >> 8 # Everything succeeded return 0 diff --git a/lib/portage/sync/controller.py b/lib/portage/sync/controller.py index 6b47ae953..93cf7bfb4 100644 --- a/lib/portage/sync/controller.py +++ b/lib/portage/sync/controller.py @@ -44,8 +44,8 @@ class TaskHandler: def run_tasks(self, tasks, func, status=None, verbose=True, options=None): """Runs the module tasks""" # Ensure we have a task and function - assert(tasks) - assert(func) + assert tasks + assert func for task in tasks: inst = task() show_progress = self.show_progress_bar and self.isatty diff --git a/lib/portage/sync/modules/rsync/rsync.py b/lib/portage/sync/modules/rsync/rsync.py index 4ccf7769f..cf574208d 100644 --- a/lib/portage/sync/modules/rsync/rsync.py +++ b/lib/portage/sync/modules/rsync/rsync.py @@ -293,7 +293,7 @@ class RsyncSync(NewBase): effective_maxretries = len(uris) - 1 local_state_unchanged = True - while (1): + while 1: if uris: dosyncuri = uris.pop() elif maxretries < 0 or retries > maxretries: @@ -304,7 +304,7 @@ class RsyncSync(NewBase): uris.extend(uris_orig) dosyncuri = uris.pop() - if (retries==0): + if retries == 0: if "--ask" in opts: uq = UserQuery(opts) if uq.query("Do you want to sync your ebuild repository " + \ @@ -422,7 +422,7 @@ class RsyncSync(NewBase): openpgp_env.close() def _process_exitcode(self, exitcode, syncuri, out, maxretries): - if (exitcode==0): + if exitcode == 0: pass elif exitcode == SERVER_OUT_OF_DATE: exitcode = 1 @@ -430,7 +430,7 @@ class RsyncSync(NewBase): sys.stderr.write( ">>> Exceeded PORTAGE_RSYNC_RETRIES: %s\n" % maxretries) exitcode = 1 - elif (exitcode>0): + elif exitcode > 0: msg = [] if exitcode==1: msg.append("Rsync has reported that there is a syntax error. Please ensure") diff --git a/lib/portage/tests/resolver/ResolverPlayground.py b/lib/portage/tests/resolver/ResolverPlayground.py index 1e382002a..89feea47a 100644 --- a/lib/portage/tests/resolver/ResolverPlayground.py +++ b/lib/portage/tests/resolver/ResolverPlayground.py @@ -756,7 +756,7 @@ class ResolverPlaygroundTestCase: if match and self.merge_order_assertions: for node1, node2 in self.merge_order_assertions: - if not (got.index(node1) < got.index(node2)): + if not got.index(node1) < got.index(node2): fail_msgs.append("atoms: (" + \ ", ".join(result.atoms) + "), key: " + \ ("merge_order_assertions, expected: %s" % \ diff --git a/lib/portage/util/__init__.py b/lib/portage/util/__init__.py index 84f1391f6..c14c15fe8 100644 --- a/lib/portage/util/__init__.py +++ b/lib/portage/util/__init__.py @@ -787,7 +787,7 @@ def varexpand(mystring, mydict=None, error_leader=None): while pos < length: current = mystring[pos] if current == "'": - if (indoub): + if indoub: newstring.append("'") else: newstring.append("'") # Quote removal is handled by shlex. @@ -795,7 +795,7 @@ def varexpand(mystring, mydict=None, error_leader=None): pos += 1 continue elif current == '"': - if (insing): + if insing: newstring.append('"') else: newstring.append('"') # Quote removal is handled by shlex. diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py index 7a2ee2551..f130b6f6b 100644 --- a/lib/portage/util/env_update.py +++ b/lib/portage/util/env_update.py @@ -182,7 +182,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, oldld = None newld = specials["LDPATH"] - if (oldld != newld): + if oldld != newld: #ld.so.conf needs updating and ldconfig needs to be run myfd = atomic_ofstream(ldsoconf_path) myfd.write("# ld.so.conf autogenerated by env-update; make all changes to\n") diff --git a/lib/portage/xpak.py b/lib/portage/xpak.py index 746ef6f5a..2a4bcda21 100644 --- a/lib/portage/xpak.py +++ b/lib/portage/xpak.py @@ -213,7 +213,7 @@ def getindex_mem(myindex): myindexlen = len(myindex) startpos = 0 myret = [] - while ((startpos + 8) < myindexlen): + while (startpos + 8) < myindexlen: mytestlen = decodeint(myindex[startpos:startpos + 4]) myret = myret + [myindex[startpos + 4:startpos + 4 + mytestlen]] startpos = startpos + mytestlen + 12 @@ -227,7 +227,7 @@ def searchindex(myindex, myitem): mylen = len(myitem) myindexlen = len(myindex) startpos = 0 - while ((startpos + 8) < myindexlen): + while (startpos + 8) < myindexlen: mytestlen = decodeint(myindex[startpos:startpos + 4]) if mytestlen == mylen: if myitem == myindex[startpos + 4:startpos + 4 + mytestlen]: @@ -251,7 +251,7 @@ def xpand(myid, mydest): mydata = myid[1] myindexlen = len(myindex) startpos = 0 - while ((startpos + 8) < myindexlen): + while (startpos + 8) < myindexlen: namelen = decodeint(myindex[startpos:startpos + 4]) datapos = decodeint(myindex[startpos + 4 + namelen:startpos + 8 + namelen]) datalen = decodeint(myindex[startpos + 8 + namelen:startpos + 12 + namelen]) @@ -439,7 +439,7 @@ class tbz2: if not os.path.exists(mydest): os.makedirs(mydest) startpos = 0 - while ((startpos + 8) < self.indexsize): + while (startpos + 8) < self.indexsize: namelen = decodeint(self.index[startpos:startpos + 4]) datapos = decodeint(self.index[startpos + 4 + namelen:startpos + 8 + namelen]) datalen = decodeint(self.index[startpos + 8 + namelen:startpos + 12 + namelen]) @@ -472,7 +472,7 @@ class tbz2: encoding=_encodings['fs'], errors='strict'), 'rb') mydata = {} startpos = 0 - while ((startpos + 8) < self.indexsize): + while (startpos + 8) < self.indexsize: namelen = decodeint(self.index[startpos:startpos + 4]) datapos = decodeint(self.index[startpos + 4 + namelen:startpos + 8 + namelen]) datalen = decodeint(self.index[startpos + 8 + namelen:startpos + 12 + namelen]) diff --git a/pylintrc b/pylintrc index b7091516c..b7efcb43e 100644 --- a/pylintrc +++ b/pylintrc @@ -22,6 +22,7 @@ enable= redefined-builtin, reimported, relative-beyond-top-level, + superfluous-parens, trailing-comma-tuple, trailing-newlines, trailing-whitespace, -- 2.28.0