From 061598f0111661950ffd883c20b050de064c5025 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Thu, 4 Dec 2014 08:21:53 -0800 Subject: [PATCH] Change from numeric to symbolic pylint error codes --- .pylint | 11 +++++++---- Makefile | 3 ++- examples/cluster.py | 11 ++++++----- mininet/cli.py | 15 +++++---------- mininet/log.py | 6 +++--- mininet/net.py | 4 ++-- mininet/topo.py | 4 ++-- mininet/topolib.py | 6 +++--- mininet/util.py | 9 ++++----- 9 files changed, 34 insertions(+), 35 deletions(-) diff --git a/.pylint b/.pylint index bd203fc..469a744 100644 --- a/.pylint +++ b/.pylint @@ -41,16 +41,19 @@ load-plugins= # can either give multiple identifier separated by comma (,) or put this option # multiple time (only on the command line, not in the configuration file where # it should appear only once). -disable=W0704,C0103,W0231,E1102,W0511,W0142,R0902,R0903,R0904,R0913,R0914,R0801,I0011,C0326 - +disable=pointless-except, invalid-name, super-init-not-called, fixme, star-args, + too-many-instance-attributes, too-few-public-methods, too-many-arguments, + too-many-locals, too-many-public-methods, duplicate-code, bad-whitespace, + locally-disabled [REPORTS] # Set the output format. Available formats are text, parseable, colorized, msvs # (visual studio) and html output-format=colorized +msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}' -# Include message's id in outpu +# Include message's id in output include-ids=yes # Put messages in a separate file for each module / package specified on the @@ -191,7 +194,7 @@ additional-builtins= ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by # List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp +defining-attr-methods=__init__,__new__,setUp,build # checks for sign of poor/misdesign: diff --git a/Makefile b/Makefile index fe15d14..a395a13 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ DOCDIRS = doc/html doc/latex PDF = doc/latex/refman.pdf CFLAGS += -Wall -Wextra -PLFMT = --msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}' +PLFMT = +# was: --msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}' all: codecheck test diff --git a/examples/cluster.py b/examples/cluster.py index 54c95df..c47ab7b 100755 --- a/examples/cluster.py +++ b/examples/cluster.py @@ -181,14 +181,13 @@ class RemoteMixin( object ): if self.isRemote: kwargs.update( mnopts='-c' ) super( RemoteMixin, self ).startShell( *args, **kwargs ) - if self.splitInit: - self.sendCmd( 'echo $$' ) - else: - self.pid = int( self.cmd( 'echo $$' ) ) + # Optional split initialization + self.sendCmd( 'echo $$' ) + if not self.splitInit: + self.finishInit() def finishInit( self ): "Wait for split initialization to complete" - assert self # please pylint self.pid = int( self.waitOutput() ) def rpopen( self, *cmd, **opts ): @@ -283,7 +282,9 @@ class RemoteOVSSwitch( RemoteMixin, OVSSwitch ): "Is remote switch using an old OVS version?" cls = type( self ) if self.server not in cls.OVSVersions: + # pylint: disable=not-callable vers = self.cmd( 'ovs-vsctl --version' ) + # pylint: enable=not-callable cls.OVSVersions[ self.server ] = re.findall( r'\d+\.\d+', vers )[ 0 ] return ( StrictVersion( cls.OVSVersions[ self.server ] ) < diff --git a/mininet/cli.py b/mininet/cli.py index 42ad779..b92b7e9 100644 --- a/mininet/cli.py +++ b/mininet/cli.py @@ -93,11 +93,6 @@ class CLI( Cmd ): self.locals.update( self.mn ) return self.locals - # Disable pylint "Unused argument: 'arg's'" messages, as well as - # "method could be a function" warning, since each CLI function - # must have the same interface - # pylint: disable=R0201 - helpStr = ( 'You may also send a command to a node using:\n' ' command {args}\n' @@ -139,10 +134,11 @@ class CLI( Cmd ): def do_sh( self, line ): """Run an external shell command Usage: sh [cmd args]""" + assert self # satisfy pylint and allow override call( line, shell=True ) # do_py() and do_px() need to catch any exception during eval()/exec() - # pylint: disable=W0703 + # pylint: disable=broad-except def do_py( self, line ): """Evaluate a Python expression. @@ -159,7 +155,7 @@ class CLI( Cmd ): output( str( e ) + '\n' ) # We are in fact using the exec() pseudo-function - # pylint: disable=W0122 + # pylint: disable=exec-used def do_px( self, line ): """Execute a Python statement. @@ -169,7 +165,7 @@ class CLI( Cmd ): except Exception, e: output( str( e ) + '\n' ) - # pylint: enable=W0703,W0122 + # pylint: enable=broad-except,exec-used def do_pingall( self, line ): "Ping between all hosts." @@ -284,6 +280,7 @@ class CLI( Cmd ): def do_exit( self, _line ): "Exit" + assert self # satisfy pylint and allow override return 'exited by user command' def do_quit( self, line ): @@ -398,8 +395,6 @@ class CLI( Cmd ): else: error( '*** Unknown command: %s\n' % line ) - # pylint: enable=R0201 - def waitForNode( self, node ): "Wait for a node to finish, and print its output." # Pollers diff --git a/mininet/log.py b/mininet/log.py index b351eb8..829dc17 100644 --- a/mininet/log.py +++ b/mininet/log.py @@ -124,8 +124,8 @@ class MininetLogger( Logger, object ): self.setLevel( level ) self.handlers[ 0 ].setLevel( level ) - # pylint: disable=E0202 - # "An attribute inherited from mininet.log hide this method" + # pylint: disable=method-hidden + # "An attribute inherited from mininet.log hide this method" (sic) # Not sure why this is occurring - this function definitely gets called. # See /usr/lib/python2.5/logging/__init__.py; modified from warning() @@ -142,7 +142,7 @@ class MininetLogger( Logger, object ): if self.isEnabledFor( OUTPUT ): self._log( OUTPUT, msg, args, kwargs ) - # pylint: enable=E0202 + # pylint: enable=method-hidden lg = MininetLogger() diff --git a/mininet/net.py b/mininet/net.py index 832199f..da3f9a3 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -254,9 +254,9 @@ class Mininet( object ): if isinstance( name, Controller ): controller_new = name # Pylint thinks controller is a str() - # pylint: disable=E1103 + # pylint: disable=maybe-no-member name = controller_new.name - # pylint: enable=E1103 + # pylint: enable=maybe-no-member else: controller_new = controller( name, **params ) # Add new controller to net diff --git a/mininet/topo.py b/mininet/topo.py index 3856a49..bd4e2fb 100644 --- a/mininet/topo.py +++ b/mininet/topo.py @@ -289,7 +289,7 @@ class Topo( object ): # Our idiom defines additional parameters in build(param...) -# pylint: disable=arguments-differ, attribute-defined-outside-init +# pylint: disable=arguments-differ class SingleSwitchTopo( Topo ): "Single switch connected to k hosts." @@ -345,4 +345,4 @@ class LinearTopo( Topo ): self.addLink( switch, lastSwitch ) lastSwitch = switch -# pylint: enable=arguments-differ, attribute-defined-outside-init +# pylint: enable=arguments-differ diff --git a/mininet/topolib.py b/mininet/topolib.py index f78acc8..6bd4562 100644 --- a/mininet/topolib.py +++ b/mininet/topolib.py @@ -3,8 +3,8 @@ from mininet.topo import Topo from mininet.net import Mininet -# The build() method is expected to do both of these things: -# pylint: disable=attribute-defined-outside-init, arguments-differ +# The build() method is expected to do this: +# pylint: disable=arguments-differ class TreeTopo( Topo ): "Topology for a tree network with a given depth and fanout." @@ -69,4 +69,4 @@ class TorusTopo( Topo ): self.addLink( sw1, sw2 ) self.addLink( sw1, sw3 ) -# pylint: enable=attribute-defined-outside-init, arguments-differ +# pylint: enable=arguments-differ diff --git a/mininet/util.py b/mininet/util.py index 32aa591..277d057 100644 --- a/mininet/util.py +++ b/mininet/util.py @@ -25,7 +25,7 @@ def checkRun( cmd ): return check_call( cmd.split( ' ' ) ) # pylint doesn't understand explicit type checking -# pylint: disable=E1103 +# pylint: disable=maybe-no-member def oldQuietRun( *cmd ): """Run a command, routing stderr to stdout, and return the output. @@ -119,8 +119,7 @@ def quietRun( cmd, **kwargs ): "Run a command and return merged stdout and stderr" return errRun( cmd, stderr=STDOUT, **kwargs )[ 0 ] -# pylint: enable=E1103 -# pylint: disable=E1101 +# pylint: enable=maybe-no-member def isShellBuiltin( cmd ): "Return True if cmd is a bash builtin." @@ -133,8 +132,6 @@ def isShellBuiltin( cmd ): isShellBuiltin.builtIns = None -# pylint: enable=E1101 - # Interface management # # Interfaces are managed as strings which are simply the @@ -431,6 +428,8 @@ def fixLimits(): except Exception: warn( "*** Error setting resource limits. " "Mininet's performance may be affected.\n" ) + # pylint: enable=broad-except + def mountCgroups(): "Make sure cgroups file system is mounted"