--- a/src/modules/client/api.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/client/api.py Wed Oct 12 13:40:52 2016 -0700
@@ -70,11 +70,7 @@
import threading
import time
from functools import cmp_to_key
-# Pylint seems to be panic about six even if it is installed. Instead of using
-# 'disable' here, a better way is to use ignore-modules in pylintrc, but
-# it has an issue that is not fixed until recently. See pylint/issues/#223.
-# import-error; pylint: disable=F0401
-# no-name-in-module; pylint: disable=E0611
+# Imports from package six are not grouped: pylint: disable=C0412
from six.moves.urllib.parse import unquote
import pkg.catalog as catalog
@@ -354,7 +350,7 @@
if global_settings.client_name is None:
global_settings.client_name = pkg_client_name
- if cmdpath == None:
+ if cmdpath is None:
cmdpath = misc.api_cmdpath()
self.cmdpath = cmdpath
@@ -596,7 +592,7 @@
before the exception is passed on.
"""
- if log_op_end == None:
+ if log_op_end is None:
log_op_end = []
# we always explicitly handle apx.ExpiringCertificate
@@ -1368,7 +1364,7 @@
# sanity checks
assert _op in api_op_values
- assert _ad_kwargs == None or \
+ assert _ad_kwargs is None or \
_op in [API_OP_ATTACH, API_OP_DETACH]
assert _ad_kwargs != None or \
_op not in [API_OP_ATTACH, API_OP_DETACH]
@@ -1530,6 +1526,8 @@
self._img.imageplan.update_index = _update_index
self.__plan_common_finish()
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
if DebugValues["plandesc_validate"]:
# save, load, and get a new json copy of the plan,
# then compare that new copy against our current one.
@@ -1974,7 +1972,7 @@
'gen_plan_sync' functions for an explanation of their usage
and effects."""
- if li_props == None:
+ if li_props is None:
li_props = dict()
op = API_OP_ATTACH
@@ -2789,7 +2787,7 @@
be = bootenv.BootEnvNull(self._img)
self._img.bootenv = be
- if self.__new_be == False and \
+ if not self.__new_be and \
self._img.imageplan.reboot_needed() and \
self._img.is_liveroot():
e = apx.RebootNeededOnLiveImageException()
@@ -2798,7 +2796,7 @@
# Before proceeding, create a backup boot environment if
# requested.
- if self.__backup_be == True:
+ if self.__backup_be:
try:
be.create_backup_be(
be_name=self.__backup_be_name)
@@ -2815,7 +2813,7 @@
# After (possibly) creating backup be, determine if
# operation should execute on a clone of current BE.
- if self.__new_be == True:
+ if self.__new_be:
try:
be.init_image_recovery(self._img,
self.__be_name)
@@ -2851,7 +2849,7 @@
if not self._img.linked.nothingtodo():
self._img.linked.syncmd()
except RuntimeError as e:
- if self.__new_be == True:
+ if self.__new_be:
be.restore_image()
else:
be.restore_install_uninstall()
@@ -2878,7 +2876,7 @@
raise error
except Exception as e:
- if self.__new_be == True:
+ if self.__new_be:
be.restore_image()
else:
be.restore_install_uninstall()
@@ -2891,7 +2889,7 @@
exc_type, exc_value, exc_traceback = \
sys.exc_info()
- if self.__new_be == True:
+ if self.__new_be:
be.restore_image()
else:
be.restore_install_uninstall()
@@ -2914,7 +2912,7 @@
def __finished_execution(self, be):
if self._img.imageplan.state != plandesc.EXECUTED_OK:
- if self.__new_be == True:
+ if self.__new_be:
be.restore_image()
else:
be.restore_install_uninstall()
@@ -2929,7 +2927,7 @@
self.__new_be:
be.update_boot_archive()
- if self.__new_be == True:
+ if self.__new_be:
be.activate_image(set_active=self.__be_activate)
else:
be.activate_install_uninstall()
@@ -3344,6 +3342,8 @@
pkg_repos = {}
pkg_pub_map = {}
+ # Too many nested blocks;
+ # pylint: disable=R0101
try:
progtrack.refresh_start(len(pubs), full_refresh=False)
failed = []
@@ -3595,7 +3595,7 @@
rids = tuple(sorted(
pkg_pub_map[pub][stem][ver]))
- if not rids in rid_map:
+ if rids not in rid_map:
# Create a publisher and
# repository for this
# unique set of origins.
@@ -3943,6 +3943,8 @@
pubs = sorted(pubs, key=pub_key)
+ # Too many nested blocks;
+ # pylint: disable=R0101
ranked_stems = {}
for t, entry, actions in pkg_cat.entry_actions(cat_info,
cb=filter_cb, excludes=excludes, last=use_last,
@@ -4526,7 +4528,7 @@
if self.__can_be_canceled == status:
return
- if status == True:
+ if status:
# Callers must hold activity lock for operations
# that they will make cancelable.
assert self._activity_lock._is_owned()
--- a/src/modules/client/linkedimage/common.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/client/linkedimage/common.py Wed Oct 12 13:40:52 2016 -0700
@@ -50,7 +50,7 @@
import six
# Redefining built-in 'reduce', 'zip'; pylint: disable=W0622
-# import-error: six.moves; pylint: disable=F0401
+# Imports from package six are not grouped: pylint: disable=C0412
from functools import reduce
from six.moves import zip
@@ -550,7 +550,7 @@
new properties, updates them, and resets any cached state
that is affected by property values."""
- if props == None:
+ if props is None:
props = dict()
elif props:
self.__verify_props(props)
@@ -989,7 +989,7 @@
# compare in-memory and on-disk properties
li_ondisk_props = self.__load_ondisk_props(tmp=False)
- if li_ondisk_props == None:
+ if li_ondisk_props is None:
li_ondisk_props = dict()
li_inmemory_props = rm_dict_ent(self.__props,
temporal_props)
@@ -1060,7 +1060,7 @@
pubs = get_pubs(self.__img)
ppubs = self.__ppubs
- if ppubs == None:
+ if ppubs is None:
# parent publisher data is missing, press on and hope
# for the best.
return
@@ -1232,7 +1232,7 @@
Always returns a copy of the properties in case the caller
tries to update them."""
- if lin == None:
+ if lin is None:
# If we're not linked we'll return an empty
# dictionary. That's ok.
return self.__props.copy()
@@ -1334,7 +1334,7 @@
# sort by linked image name
li_children = sorted(li_children, key=operator.itemgetter(0))
- if li_ignore == None:
+ if li_ignore is None:
# don't ignore any children
return li_children
@@ -1403,9 +1403,9 @@
assert type(lin) == LinkedImageName
assert type(path) == str
- assert props == None or type(props) == dict, \
+ assert props is None or type(props) == dict, \
"type(props) == {0}".format(type(props))
- if props == None:
+ if props is None:
props = dict()
lip = self.__plugins[lin.lin_type]
@@ -1419,7 +1419,7 @@
# Path must be an absolute path.
if not os.path.isabs(path):
- raise apx.LinkedImageException(parent_path_notabs=path)
+ raise apx.LinkedImageException(parent_bad_notabs=path)
# we don't bother to cleanup the path to the parent image here
# because when we allocate an Image object for the parent
@@ -1706,10 +1706,7 @@
# Unused variable 'be_uuid'; pylint: disable=W0612
(be_name, be_uuid) = bootenv.BootEnv.get_be_name(self.__root)
# pylint: enable=W0612
- if be_name:
- img_is_clonable = True
- else:
- img_is_clonable = False
+ img_is_clonable = bool(be_name)
# If the parent image is clonable then the new child image
# must be nested within the parents filesystem namespace.
@@ -1824,9 +1821,9 @@
assert type(lin) == LinkedImageName
assert type(path) == str
- assert props == None or type(props) == dict, \
+ assert props is None or type(props) == dict, \
"type(props) == {0}".format(type(props))
- if props == None:
+ if props is None:
props = dict()
lip = self.__plugins[lin.lin_type]
@@ -3698,32 +3695,32 @@
assert not (li and lic)
assert not ((lin or path) and li)
assert not ((lin or path) and lic)
- assert path == None or type(path) == str
+ assert path is None or type(path) == str
if bad_cp:
- assert err == None
+ assert err is None
err = "Invalid linked content policy: {0}".format(bad_cp)
elif bad_iup:
- assert err == None
+ assert err is None
err = "Invalid linked image update policy: {0}".format(bad_iup)
elif bad_lin_type:
- assert err == None
+ assert err is None
err = "Invalid linked image type: {0}".format(bad_lin_type)
elif bad_prop:
- assert err == None
+ assert err is None
err = "Invalid linked property value: {0}={1}".format(*bad_prop)
elif missing_props:
- assert err == None
+ assert err is None
err = "Missing required linked properties: {0}".format(
", ".join(missing_props))
elif multiple_transforms:
- assert err == None
+ assert err is None
err = "Multiple plugins reported different path transforms:"
for plugin, transform in multiple_transforms:
err += "\n\t{0} = {1} -> {2}".format(plugin,
transform[0], transform[1])
elif saved_temporal_props:
- assert err == None
+ assert err is None
err = "Found saved temporal linked properties: {0}".format(
", ".join(saved_temporal_props))
else:
--- a/src/modules/client/pkg_solver.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/client/pkg_solver.py Wed Oct 12 13:40:52 2016 -0700
@@ -31,26 +31,26 @@
import six
import time
+from collections import defaultdict
+# Redefining built-in; pylint: disable=W0622
+from functools import reduce
+# Imports from package six are not grouped: pylint: disable=C0412
+from six.moves import range
+
import pkg.actions
-import pkg.catalog as catalog
+import pkg.catalog as catalog
import pkg.client.api_errors as api_errors
-
import pkg.client.image
import pkg.fmri
import pkg.misc as misc
import pkg.solver
-import pkg.version as version
-
-from collections import defaultdict
-# Redefining built-in; pylint: disable=W0622
-from functools import reduce
+import pkg.version as version
+
from pkg.actions.depend import known_types as dep_types
from pkg.client.debugvalues import DebugValues
from pkg.client.firmware import Driver, Cpu
from pkg.client.pkgdefs import PKG_OP_UNINSTALL, PKG_OP_UPDATE
from pkg.misc import EmptyI, EmptyDict, N_
-# Unable to import; pylint: disable=F0401
-from six.moves import range
SOLVER_INIT = "Initialized"
SOLVER_OXY = "Not possible"
@@ -132,6 +132,8 @@
the set of pkg stems being avoided in the image due to
administrator action (e.g. --reject, uninstall)."""
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
# check if we're allowed to use the solver
if DebugValues["no_solver"]:
raise RuntimeError("no_solver set, but solver invoked")
@@ -324,6 +326,8 @@
self.__dg_incorp_cache = None
self.__linked_pkgs = set()
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
if DebugValues["plan"]:
# Remaining data must be kept.
return rval
@@ -376,6 +380,8 @@
"""Raise a plan exception due to solution errors."""
solver_errors = None
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
if DebugValues["plan"]:
solver_errors = self.get_trim_errors()
raise api_errors.PlanCreationException(no_solution=no_solution,
@@ -839,6 +845,8 @@
"you wish installed."))
exp.no_solution = incs + info
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
if DebugValues["plan"]:
exp.solver_errors = self.get_trim_errors()
raise exp
@@ -2332,7 +2340,7 @@
# check if allowing obsolete packages helps
- elif obsolete_ok == False:
+ elif not obsolete_ok:
# see if allowing obsolete pkgs gets us some matches
if len(fmris) == 1:
matching, nonmatching = \
@@ -2455,6 +2463,8 @@
# At a minimum, a solve_*() method must have been called first.
assert self.__state != SOLVER_INIT
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
assert DebugValues["plan"]
return self.__fmri_list_errors(six.iterkeys(self.__trim_dict),
--- a/src/modules/client/pkgdefs.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/client/pkgdefs.py Wed Oct 12 13:40:52 2016 -0700
@@ -199,4 +199,3 @@
# Message types
MSG_GENERAL = "general"
MSG_UNPACKAGED = "unpackaged"
-
--- a/src/modules/client/pkgremote.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/client/pkgremote.py Wed Oct 12 13:40:52 2016 -0700
@@ -143,6 +143,7 @@
# module subprocess here.
# unexpected-keyword-arg 'pass_fds';
# pylint: disable=E1123
+ # Redefinition of p type
if six.PY2:
p = pkg.pkgsubprocess.Popen(pkg_cmd,
stdout=fstdout, stderr=fstderr)
--- a/src/modules/client/plandesc.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/client/plandesc.py Wed Oct 12 13:40:52 2016 -0700
@@ -422,8 +422,8 @@
"version-source")
return mimpl, mver, mimpl_source, mver_source
- for m in sorted(set(list(self._new_mediators.keys()) +
- list(self._cfg_mediators.keys()))):
+ for m in sorted(set(self._new_mediators) |
+ set(self._cfg_mediators)):
orig_impl, orig_ver, orig_impl_source, \
orig_ver_source = get_mediation(
self._cfg_mediators, m)
@@ -532,6 +532,8 @@
# dict[(<facet, src>)] = (<value>, <masked>)
old_facets = dict([
((f, src), (v, masked))
+ # not-an-iterable self._old_facets;
+ # pylint: disable=E1133
for f in self._old_facets
# W0212 Access to a protected member
# pylint: disable=W0212
@@ -539,6 +541,8 @@
])
new_facets = dict([
((f, src), (v, masked))
+ # not-an-iterable self._new_facets;
+ # pylint: disable=E1133
for f in self._new_facets
# W0212 Access to a protected member
# pylint: disable=W0212
--- a/src/modules/client/printengine.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/client/printengine.py Wed Oct 12 13:40:52 2016 -0700
@@ -345,4 +345,3 @@
pe.cprint("This should be on the next line (with no nl's intervening).")
# just test that it works
pe.isslow()
-
--- a/src/modules/client/progress.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/client/progress.py Wed Oct 12 13:40:52 2016 -0700
@@ -38,9 +38,10 @@
import simplejson as json
import six
import time
+from collections import deque
from functools import wraps
# Redefining built-in 'range'; pylint: disable=W0622
-# import-error: six.moves; pylint: disable=F0401
+# Imports from package six are not grouped: pylint: disable=C0412
from six.moves import range
import pkg.client.pkgdefs as pkgdefs
@@ -52,8 +53,6 @@
from pkg.client import printengine
logger = global_settings.logger
-from collections import deque
-
class ProgressTrackerException(Exception):
"""Thrown if a ProgressTracker determines that it can't be instantiated.
For example, the tracker which depends on a UNIX style terminal should
@@ -230,10 +229,8 @@
# used ctrl-z and then resumed; disable the estimate until we
# build up more data.
#
- if len(self.__deque) < 10 or timelapse < (self.INTERVAL / 20.0):
- self.__noestimate = True
- else:
- self.__noestimate = False
+ self.__noestimate = bool(len(self.__deque) < 10 or
+ timelapse < (self.INTERVAL / 20.0))
curspeed = self.__intervalbytes / timelapse
@@ -2400,7 +2397,7 @@
# adjusts the output based on the major phase.
#
goalitems = self.mfst_fetch.goalitems
- if goalitems == None:
+ if goalitems is None:
goalitems = 0
prog_json = {self.O_PHASE: self._phase_prefix(),
self.O_MESSAGE: _("Fetching manifests"),
@@ -3176,7 +3173,7 @@
print("Use ctrl-c to skip sections")
- if gofast == False:
+ if not gofast:
fast = 1.0
else:
fast = 0.10
--- a/src/modules/misc.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/misc.py Wed Oct 12 13:40:52 2016 -0700
@@ -54,15 +54,11 @@
import urllib
import zlib
+# ungrouped-imports: pylint: disable=C0412
from binascii import hexlify, unhexlify
from collections import defaultdict
from io import BytesIO
from operator import itemgetter
-# Pylint seems to be panic about six even if it is installed. Instead of using
-# 'disable' here, a better way is to use ignore-modules in pylintrc, but
-# it has an issue that is not fixed until recently. See pylint/issues/#223.
-# import-error; pylint: disable=F0401
-# no-name-in-module; pylint: disable=E0611
# Redefining built-in 'range'; pylint: disable=W0622
# Module 'urllib' has no 'parse' member; pylint: disable=E1101
from six.moves import range, zip_longest
@@ -1032,7 +1028,7 @@
def __setitem__(self, item, value):
self.__oops()
- def __delitem__(self, item, value):
+ def __delitem__(self, item):
self.__oops()
def pop(self, item, default=None):
@@ -1982,6 +1978,8 @@
data = { "json_state": data, "json_objects": obj_cache2 }
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
if DebugValues["plandesc_validate"]:
json_validate(name, data)
@@ -2591,6 +2589,8 @@
# Catch "Exception"; pylint: disable=W0703
try:
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
if DebugValues["async_thread_error"]:
raise Exception("async_thread_error")
@@ -2611,6 +2611,8 @@
self.e = self.__e
self.e.e = e
try:
+ # Value 'DebugValues' is unsubscriptable;
+ # pylint: disable=E1136
if DebugValues["async_thread_error"]:
raise Exception("async_thread_error")
self.e.tb = traceback.format_exc()
@@ -2832,6 +2834,8 @@
a = ""
line.append(a)
+ # Too many boolean expressions in if statement;
+ # pylint: disable=R0916
if (line and [l for l in line if str(l) != ""] or show_all) \
and (not remove_consec_dup_lines or last_line is None or
last_line != line):
--- a/src/modules/pipeutils.py Tue Oct 11 14:41:18 2016 -0700
+++ b/src/modules/pipeutils.py Wed Oct 12 13:40:52 2016 -0700
@@ -81,8 +81,6 @@
import threading
import traceback
-from pkg.misc import force_bytes, force_str
-
# import JSON RPC libraries and objects
import jsonrpclib as rpclib
import jsonrpclib.jsonrpc as rpc
@@ -91,12 +89,6 @@
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCDispatcher as \
SimpleRPCDispatcher
-# jsonrpclib 0.2.6's SimpleJSONRPCServer makes logging calls, but we don't
-# configure logging in this file, so we attach a do-nothing handler to it to
-# prevent error message being output to sys.stderr.
-logging.getLogger("jsonrpclib.SimpleJSONRPCServer").addHandler(
- logging.NullHandler())
-
#
# These includes make it easier for clients to catch the specific
# exceptions that can be raised by this module.
@@ -104,12 +96,18 @@
# Unused import; pylint: disable=W0611
from jsonrpclib import ProtocolError as ProtocolError1
-# import-error; pylint: disable=F0401
-# no-name-in-module; pylint: disable=E0611
from six.moves import socketserver, http_client
from six.moves.xmlrpc_client import ProtocolError as ProtocolError2
# Unused import; pylint: enable=W0611
+from pkg.misc import force_bytes, force_str
+
+# jsonrpclib 0.2.6's SimpleJSONRPCServer makes logging calls, but we don't
+# configure logging in this file, so we attach a do-nothing handler to it to
+# prevent error message being output to sys.stderr.
+logging.getLogger("jsonrpclib.SimpleJSONRPCServer").addHandler(
+ logging.NullHandler())
+
# debugging
pipeutils_debug = (os.environ.get("PKG_PIPEUTILS_DEBUG", None) is not None)
@@ -241,6 +239,8 @@
def readinto(self, b):
"""Read up to len(b) bytes into the writable buffer *b* and
return the numbers of bytes read."""
+ # not-context-manager for py 2.7;
+ # pylint: disable=E1129
with memoryview(b) as view:
data = self.read(len(view))
view[:len(data)] = force_bytes(data)
@@ -398,7 +398,7 @@
# self.sock was initialized by httplib.HTTPConnection
# to point to a socket, overwrite it with a pipe.
- assert(type(fd) == int) and os.fstat(fd)
+ assert type(fd) == int and os.fstat(fd)
self.sock = PipeSocket(fd, "client-connection")
def __del__(self):
@@ -444,7 +444,7 @@
self.__pipe_file.close()
self.__pipe_file = None
- def make_connection(self, host):
+ def make_connection(self, host): # Unused argument 'host'; pylint: disable=W0613
"""Create a new PipedHTTP connection to the server. This
involves creating a new pipe, and sending one end of the pipe
to the server, and then wrapping the local end of the pipe
--- a/src/tests/pylintrc Tue Oct 11 14:41:18 2016 -0700
+++ b/src/tests/pylintrc Wed Oct 12 13:40:52 2016 -0700
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
-# Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This file is used to control pylint when checking python source
@@ -69,10 +69,11 @@
# W0141 Used builtin function '%s'
# W0142 Used * or ** magic
# W0614 Unused import %s from wildcard import
-# W1504 Unidiomatic typecheck
# I0011 Locally disabling %r
# I0012 Locally enabling %s (%s)
-disable=C0103,C0302,C0326,C0330,R0901,R0902,R0904,R0911,R0912,R0913,R0914,R0915,R0923,W0141,W0142,W0614,W1504,I0011,I0012
+# R0204 Redefined variable type
+# C0123 Unidiomatic typecheck
+disable=C0103,C0302,C0326,C0330,R0901,R0902,R0904,R0911,R0912,R0913,R0914,R0915,R0923,W0141,W0142,W0614,I0011,I0012,R0204,C0123
[REPORTS]
# set the output format. Available formats are text, parseable, colorized, msvs
@@ -118,9 +119,6 @@
#
[BASIC]
-# Required attributes for module, separated by a comma
-required-attributes=
-
# Regular expression which should only match functions or classes name which do
# not require a docstring
no-docstring-rgx=__.*__
@@ -186,6 +184,9 @@
# * redefinition of variable from builtins or from an outer scope
# * use of variable before assigment
#
+
+ignored-modules=six.moves
+
[VARIABLES]
# Tells wether we should check for unused import in __init__ files.
@@ -212,10 +213,6 @@
#
[CLASSES]
-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-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