Re: [PATCH] lib/*: Fix useless-return

Michał Górny <[email protected]>
Newsgroups gmane.linux.gentoo.portage.devel
Organization Gentoo
Message-ID <[email protected]>
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 <[email protected]>
> ---
>  "\\"                           | 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
signature.asc (application/pgp-signature, 618 B)
-----BEGIN PGP SIGNATURE-----

iQGTBAABCgB9FiEEx2qEUJQJjSjMiybFY5ra4jKeJA4FAl8tjtBfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEM3
NkE4NDUwOTQwOThEMjhDQzhCMjZDNTYzOUFEQUUyMzI5RTI0MEUACgkQY5ra4jKe
JA76YQgAr3h3MjictKe2UL4f/WrYTRBBxk9Mrmuo2Ha1grsfBbdfZLCIXCFWx2es
IJTIYRie/g4yuhBW/EPIYv7au0AjX0sZ4JT9ClKMNEOWtwanJcps3mCgsVQdo5H5
tMcrBY4yFgsw5MpwLLUy7rWeTsKeHGXB7zEmQl/sSmI5ggd4M2N/jOkLpAlcACDh
pvZg84BJw7bzyEcIJsGAUmOGIIYTkP/oju9A4qT/XuSL2LKfOz+hBU1gGUDsGI5t
56bam9bCVSfGTqoCLAxpo20NnAmKSWRxsMuQ45SvGYYVnT0NI3C0LiP3CW5hLy/s
xtiWGAvKknKoGAT5dsdd4XHvyJyrrQ==
=AXJQ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.