public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Aaron Bauman <bman@gentoo.org>
Subject: Re: [gentoo-portage-dev] [PATCH] lib/*: Fix useless-return
Date: Fri, 07 Aug 2020 19:26:40 +0200	[thread overview]
Message-ID: <dabe66f0872674e1d3f1413f4b1316d9500a4738.camel@gentoo.org> (raw)
In-Reply-To: <20200807162804.240101-1-bman@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 9153 bytes --]

On Fri, 2020-08-07 at 12:28 -0400, Aaron Bauman wrote:
> * Python implies such things. Let's drop 'em and be consistent.
> 
> Signed-off-by: Aaron Bauman <bman@gentoo.org>
> ---
>  "\\"                           | 20 ++++++++++++++++++++
>  lib/_emerge/EbuildPhase.py     |  6 +++---
>  lib/_emerge/resolver/output.py |  5 -----
>  lib/portage/elog/mod_custom.py |  1 -
>  lib/portage/elog/mod_echo.py   |  4 ++--
>  lib/portage/elog/mod_mail.py   |  2 --
>  lib/portage/glsa.py            |  3 ---
>  lib/portage/mail.py            |  1 -
>  lib/portage/sync/controller.py |  3 +--
>  lib/portage/util/whirlpool.py  |  2 --
>  pylintrc                       |  1 +
>  11 files changed, 27 insertions(+), 21 deletions(-)
>  create mode 100644 "\\"
> 
> diff --git "a/\\" "b/\\"
> new file mode 100644
> index 000000000..aaf1d3b1b
> --- /dev/null
> +++ "b/\\"

That's an interesting file to add.

> @@ -0,0 +1,20 @@
> +# elog/mod_custom.py - elog dispatch module
> +# Copyright 2006-2020 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +import portage.elog.mod_save
> +import portage.exception
> +import portage.process
> +
> +def process(mysettings, key, logentries, fulltext):
> +	elogfilename = portage.elog.mod_save.process(mysettings, key, logentries, fulltext)
> +
> +	if not mysettings.get("PORTAGE_ELOG_COMMAND"):
> +		raise portage.exception.MissingParameter("!!! Custom logging requested but PORTAGE_ELOG_COMMAND is not defined")
> +	else:
> +		mylogcmd = mysettings["PORTAGE_ELOG_COMMAND"]
> +		mylogcmd = mylogcmd.replace("${LOGFILE}", elogfilename)
> +		mylogcmd = mylogcmd.replace("${PACKAGE}", key)
> +		retval = portage.process.spawn_bash(mylogcmd)
> +		if retval != 0:
> +			raise portage.exception.PortageException("!!! PORTAGE_ELOG_COMMAND failed with exitcode %d" % retval)
> diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
> index e6256d0aa..ceffeccee 100644
> --- a/lib/_emerge/EbuildPhase.py
> +++ b/lib/_emerge/EbuildPhase.py
> @@ -9,11 +9,12 @@ import tempfile
>  
>  from _emerge.AsynchronousLock import AsynchronousLock
>  from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor
> -from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
> -from _emerge.EbuildProcess import EbuildProcess
>  from _emerge.CompositeTask import CompositeTask
> +from _emerge.EbuildProcess import EbuildProcess
> +from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
>  from _emerge.PackagePhase import PackagePhase
>  from _emerge.TaskSequence import TaskSequence
> +
>  from portage.package.ebuild._ipc.QueryCommand import QueryCommand
>  from portage.util._dyn_libs.soname_deps_qa import (
>  	_get_all_provides,
> @@ -396,7 +397,6 @@ class EbuildPhase(CompositeTask):
>  			fd_pipes=self.fd_pipes, phase=phase, scheduler=self.scheduler,
>  			settings=self.settings)
>  		self._start_task(clean_phase, self._fail_clean_exit)
> -		return
>  
>  	def _fail_clean_exit(self, clean_phase):
>  		self._final_exit(clean_phase)
> diff --git a/lib/_emerge/resolver/output.py b/lib/_emerge/resolver/output.py
> index 1dcb47020..b6c77ecad 100644
> --- a/lib/_emerge/resolver/output.py
> +++ b/lib/_emerge/resolver/output.py
> @@ -243,7 +243,6 @@ class Display:
>  				cur_use_map[key], old_iuse_map[key],
>  				old_use_map[key], is_new, feature_flags,
>  				reinst_flags_map.get(key))
> -		return
>  
>  
>  	@staticmethod
> @@ -539,7 +538,6 @@ class Display:
>  			if show_repos and repoadd:
>  				myprint += " " + teal("[%s]" % repoadd)
>  			writemsg_stdout("%s\n" % (myprint,), noiselevel=-1)
> -		return
>  
>  
>  	def print_blockers(self):
> @@ -548,7 +546,6 @@ class Display:
>  		"""
>  		for pkg in self.blockers:
>  			writemsg_stdout("%s\n" % (pkg,), noiselevel=-1)
> -		return
>  
>  
>  	def print_verbose(self, show_repos):
> @@ -562,7 +559,6 @@ class Display:
>  			# that RepoDisplay.__unicode__() is called in python2.
>  			writemsg_stdout("%s" % (self.conf.repo_display,),
>  				noiselevel=-1)
> -		return
>  
>  
>  	def print_changelog(self):
> @@ -687,7 +683,6 @@ class Display:
>  			if ebuild_path_cl is not None:
>  				self.changelogs.extend(_calc_changelog(
>  					ebuild_path_cl, pkg_info.previous_pkg, pkg.cpv))
> -		return
>  
>  
>  	def check_system_world(self, pkg):
> diff --git a/lib/portage/elog/mod_custom.py b/lib/portage/elog/mod_custom.py
> index 7cfafeccc..aaf1d3b1b 100644
> --- a/lib/portage/elog/mod_custom.py
> +++ b/lib/portage/elog/mod_custom.py
> @@ -18,4 +18,3 @@ def process(mysettings, key, logentries, fulltext):
>  		retval = portage.process.spawn_bash(mylogcmd)
>  		if retval != 0:
>  			raise portage.exception.PortageException("!!! PORTAGE_ELOG_COMMAND failed with exitcode %d" % retval)
> -	return
> diff --git a/lib/portage/elog/mod_echo.py b/lib/portage/elog/mod_echo.py
> index 80f2b11ac..a026847b7 100644
> --- a/lib/portage/elog/mod_echo.py
> +++ b/lib/portage/elog/mod_echo.py
> @@ -3,9 +3,10 @@
>  # Distributed under the terms of the GNU General Public License v2
>  
>  import sys
> -from portage.output import EOutput, colorize
> +
>  from portage.const import EBUILD_PHASES
>  from portage.localization import _
> +from portage.output import EOutput, colorize
>  
>  
>  _items = []
> @@ -61,4 +62,3 @@ def _finalize():
>  				for line in msgcontent:
>  					fmap[msgtype](line.strip("\n"))
>  	_items = []
> -	return
> diff --git a/lib/portage/elog/mod_mail.py b/lib/portage/elog/mod_mail.py
> index 38eaa277f..f737a80ce 100644
> --- a/lib/portage/elog/mod_mail.py
> +++ b/lib/portage/elog/mod_mail.py
> @@ -41,5 +41,3 @@ def process(mysettings, key, logentries, fulltext):
>  		portage.mail.send_mail(mysettings, mymessage)
>  	except PortageException as e:
>  		writemsg("%s\n" % str(e), noiselevel=-1)
> -
> -	return
> diff --git a/lib/portage/glsa.py b/lib/portage/glsa.py
> index 9260e7e09..1870d9338 100644
> --- a/lib/portage/glsa.py
> +++ b/lib/portage/glsa.py
> @@ -492,7 +492,6 @@ class Glsa:
>  		finally:
>  			f.close()
>  
> -		return None
>  
>  	def parse(self, myfile):
>  		"""
> @@ -583,7 +582,6 @@ class Glsa:
>  			self.packages[name].append(tmp)
>  		# TODO: services aren't really used yet
>  		self.services = self.affected.getElementsByTagName("service")
> -		return None
>  
>  	def dump(self, outstream=sys.stdout, encoding="utf-8"):
>  		"""
> @@ -684,7 +682,6 @@ class Glsa:
>  				mode='a+', encoding=_encodings['content'], errors='strict')
>  			checkfile.write(_unicode_decode(self.nr + "\n"))
>  			checkfile.close()
> -		return None
>  
>  	def getMergeList(self, least_change=True):
>  		"""
> diff --git a/lib/portage/mail.py b/lib/portage/mail.py
> index 6503b4cc9..f4fccd8c2 100644
> --- a/lib/portage/mail.py
> +++ b/lib/portage/mail.py
> @@ -136,4 +136,3 @@ def send_mail(mysettings, message):
>  			raise portage.exception.PortageException(_("!!! An error occurred while trying to send logmail:\n")+str(e))
>  		except socket.error as e:
>  			raise portage.exception.PortageException(_("!!! A network error occurred while trying to send logmail:\n%s\nSure you configured PORTAGE_ELOG_MAILURI correctly?") % str(e))
> -	return
> diff --git a/lib/portage/sync/controller.py b/lib/portage/sync/controller.py
> index cb68e2c37..24ebf4ff8 100644
> --- a/lib/portage/sync/controller.py
> +++ b/lib/portage/sync/controller.py
> @@ -174,7 +174,7 @@ class SyncManager:
>  
>  
>  	def do_callback(self, result):
> -		#print("result:", result, "callback()", self.callback)
> +		# print("result:", result, "callback()", self.callback)
>  		exitcode, updatecache_flg = result
>  		self.exitcode = exitcode
>  		self.updatecache_flg = updatecache_flg
> @@ -184,7 +184,6 @@ class SyncManager:
>  			writemsg_level(msg + "\n")
>  		if self.callback:
>  			self.callback(exitcode, updatecache_flg)
> -		return
>  
>  
>  	def perform_post_sync_hook(self, reponame, dosyncuri='', repolocation=''):
> diff --git a/lib/portage/util/whirlpool.py b/lib/portage/util/whirlpool.py
> index 1071d5155..857abf3ac 100644
> --- a/lib/portage/util/whirlpool.py
> +++ b/lib/portage/util/whirlpool.py
> @@ -634,7 +634,6 @@ class WhirlpoolStruct:
>  
>  def WhirlpoolInit(ctx):
>      ctx = WhirlpoolStruct()
> -    return
>  
>  def WhirlpoolAdd(source, sourceBits, ctx):
>      if not isinstance(source, bytes):
> @@ -777,7 +776,6 @@ def processBuffer(ctx):
>      # apply the Miyaguchi-Preneel compression function
>      for i in range(8):
>          ctx.hash[i] ^= state[i] ^ block[i]
> -    return
>  
>  #
>  # Tests.
> diff --git a/pylintrc b/pylintrc
> index f2aadf14f..ce5dec11b 100644
> --- a/pylintrc
> +++ b/pylintrc
> @@ -33,6 +33,7 @@ enable=
>          unused-import,
>          useless-import-alias,
>          useless-object-inheritance,
> +        useless-return,
>          wildcard-import
>  
>  # A comma-separated list of package or module names from where C extensions may

-- 
Best regards,
Michał Górny


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

  reply	other threads:[~2020-08-07 17:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 16:28 [gentoo-portage-dev] [PATCH] lib/*: Fix useless-return Aaron Bauman
2020-08-07 17:26 ` Michał Górny [this message]
2020-08-07 19:02 ` Aaron Bauman
  -- strict thread matches above, loose matches on Subject: below --
2020-08-07 19:06 Aaron Bauman
2020-08-07 20:21 ` Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dabe66f0872674e1d3f1413f4b1316d9500a4738.camel@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=bman@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox