Skip to content

Commit

Permalink
Make pylint happy
Browse files Browse the repository at this point in the history
- fix super-with-arguments
- ignore raise-missing-from - too many intentional usages
  • Loading branch information
marmarek committed Aug 23, 2020
1 parent fe583cd commit e618623
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 79 deletions.
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extension-pkg-whitelist=lxml.etree
disable=
bad-continuation,
raising-format-tuple,
raise-missing-from,
import-outside-toplevel,
inconsistent-return-statements,
duplicate-code,
Expand Down
8 changes: 4 additions & 4 deletions qubesadmin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class in py:class:`qubesadmin.Qubes` instead, which points at
cache_enabled = False

def __init__(self):
super(QubesBase, self).__init__(self, 'admin.property.', 'dom0')
super().__init__(self, 'admin.property.', 'dom0')
self.domains = VMCollection(self)
self.labels = qubesadmin.base.WrapperObjectsCollection(
self, 'admin.label.List', qubesadmin.label.Label)
Expand Down Expand Up @@ -454,19 +454,19 @@ def clone_vm(self, src_vm, new_name, new_cls=None, pool=None, pools=None,
['qvm-appmenus', '--init', '--update',
'--source', src_vm.name, dst_vm.name]
subprocess.check_output(appmenus_cmd, stderr=subprocess.STDOUT)
except OSError:
except OSError as e:
# this file needs to be python 2.7 compatible,
# so no FileNotFoundError
self.log.error('Failed to clone appmenus, qvm-appmenus missing')
if not ignore_errors:
raise qubesadmin.exc.QubesException(
'Failed to clone appmenus')
'Failed to clone appmenus') from e
except subprocess.CalledProcessError as e:
self.log.error('Failed to clone appmenus: %s',
e.output.decode())
if not ignore_errors:
raise qubesadmin.exc.QubesException(
'Failed to clone appmenus')
'Failed to clone appmenus') from e

except qubesadmin.exc.QubesException:
if not ignore_errors:
Expand Down
4 changes: 2 additions & 2 deletions qubesadmin/backup/core2.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Core2VM(qubesadmin.backup.BackupVM):
'''VM object'''
# pylint: disable=too-few-public-methods
def __init__(self):
super(Core2VM, self).__init__()
super().__init__()
self.backup_content = False

@property
Expand Down Expand Up @@ -148,7 +148,7 @@ def __init__(self, store=None):
raise ValueError("store path required")
self.qid_map = {}
self.log = logging.getLogger('qubesadmin.backup.core2')
super(Core2Qubes, self).__init__(store)
super().__init__(store)

def load_globals(self, element):
'''Load global settings
Expand Down
2 changes: 1 addition & 1 deletion qubesadmin/backup/core3.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, store=None):
raise ValueError("store path required")
self.log = logging.getLogger('qubesadmin.backup.core3')
self.labels = {}
super(Core3Qubes, self).__init__(store)
super().__init__(store)

@staticmethod
def get_property(xml_obj, prop):
Expand Down
8 changes: 4 additions & 4 deletions qubesadmin/backup/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
class BackupCanceledError(QubesException):
'''Exception raised when backup/restore was cancelled'''
def __init__(self, msg, tmpdir=None):
super(BackupCanceledError, self).__init__(msg)
super().__init__(msg)
self.tmpdir = tmpdir

def init_supported_hmac_and_crypto():
Expand Down Expand Up @@ -361,7 +361,7 @@ def __init__(self, queue, base_dir, passphrase, encrypted,
:param bool verify_only: only verify data integrity, do not extract
:param dict handlers: handlers for actual data
'''
super(ExtractWorker3, self).__init__()
super().__init__()
#: queue with files to extract
self.queue = queue
#: paths on the queue are relative to this dir
Expand Down Expand Up @@ -904,14 +904,14 @@ class Dom0ToRestore(VMToRestore):
USERNAME_MISMATCH = object()

def __init__(self, vm, subdir=None):
super(BackupRestore.Dom0ToRestore, self).__init__(vm)
super().__init__(vm)
if subdir:
self.subdir = subdir
self.username = os.path.basename(subdir)

def __init__(self, app, backup_location, backup_vm, passphrase,
location_is_service=False, force_compression_filter=None):
super(BackupRestore, self).__init__()
super().__init__()

#: qubes.Qubes instance
self.app = app
Expand Down
4 changes: 2 additions & 2 deletions qubesadmin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def _local_properties(cls):

def __setattr__(self, key, value):
if key.startswith('_') or key in self._local_properties():
return super(PropertyHolder, self).__setattr__(key, value)
return super().__setattr__(key, value)
if value is qubesadmin.DEFAULT:
try:
self.qubesd_call(
Expand All @@ -371,7 +371,7 @@ def __setattr__(self, key, value):

def __delattr__(self, name):
if name.startswith('_') or name in self._local_properties():
return super(PropertyHolder, self).__delattr__(name)
return super().__delattr__(name)
try:
self.qubesd_call(
self._method_dest,
Expand Down
4 changes: 2 additions & 2 deletions qubesadmin/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, backend_domain, devclass, ident, description=None,
**kwargs):
if description is None:
description = "Unknown device"
super(UnknownDevice, self).__init__(backend_domain, devclass, ident,
super().__init__(backend_domain, devclass, ident,
description, **kwargs)


Expand Down Expand Up @@ -295,7 +295,7 @@ class DeviceManager(dict):
"""

def __init__(self, vm):
super(DeviceManager, self).__init__()
super().__init__()
self._vm = vm

def __missing__(self, key):
Expand Down
7 changes: 3 additions & 4 deletions qubesadmin/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class QubesException(Exception):
'''Base exception for all Qubes-related errors.'''
def __init__(self, message_format, *args, **kwargs):
# TODO: handle translations
super(QubesException, self).__init__(
super().__init__(
message_format % tuple(int(d) if d.isdigit() else d for d in args),
**kwargs)

Expand Down Expand Up @@ -164,7 +164,7 @@ def __str__(self):
class BackupRestoreError(QubesException):
'''Restoring a backup failed'''
def __init__(self, msg, backup_log=None):
super(BackupRestoreError, self).__init__(msg)
super().__init__(msg)
self.backup_log = backup_log

# pylint: disable=too-many-ancestors
Expand All @@ -177,8 +177,7 @@ class QubesPropertyAccessError(QubesDaemonAccessError, AttributeError):
'''Failed to read/write property value, cause is unknown (insufficient
permissions, no such property, invalid value, other)'''
def __init__(self, prop):
super(QubesPropertyAccessError, self).__init__(
'Failed to access \'%s\' property' % prop)
super().__init__('Failed to access \'%s\' property' % prop)

# legacy name
QubesDaemonNoResponseError = QubesDaemonAccessError
2 changes: 1 addition & 1 deletion qubesadmin/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Features(object):
# pylint: disable=too-few-public-methods

def __init__(self, vm):
super(Features, self).__init__()
super().__init__()
self.vm = vm

def __delitem__(self, key):
Expand Down
10 changes: 5 additions & 5 deletions qubesadmin/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RuleChoice(RuleOption):
'''Base class for multiple-choices rule elements'''
# pylint: disable=abstract-method
def __init__(self, value):
super(RuleChoice, self).__init__(value)
super().__init__(value)
self.allowed_values = \
[v for k, v in self.__class__.__dict__.items()
if not k.startswith('__') and isinstance(v, str) and
Expand Down Expand Up @@ -148,7 +148,7 @@ def __init__(self, value, prefixlen=None):
except socket.error:
raise ValueError('Invalid IP address: ' + host)

super(DstHost, self).__init__(value)
super().__init__(value)

@property
def rule(self):
Expand All @@ -175,7 +175,7 @@ def __init__(self, value):
raise ValueError('Ports out of range')
if self.range[0] > self.range[1]:
raise ValueError('Invalid port range')
super(DstPorts, self).__init__(
super().__init__(
str(self.range[0]) if self.range[0] == self.range[1]
else '{!s}-{!s}'.format(*self.range))

Expand All @@ -188,7 +188,7 @@ def rule(self):
class IcmpType(RuleOption):
'''ICMP packet type'''
def __init__(self, value):
super(IcmpType, self).__init__(value)
super().__init__(value)
value = int(value)
if value < 0 or value > 255:
raise ValueError('ICMP type out of range')
Expand All @@ -212,7 +212,7 @@ def rule(self):
class Expire(RuleOption):
'''Rule expire time'''
def __init__(self, value):
super(Expire, self).__init__(value)
super().__init__(value)
self.datetime = datetime.datetime.utcfromtimestamp(int(value))

@property
Expand Down
6 changes: 3 additions & 3 deletions qubesadmin/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def color(self):
qubesd_response = self.app.qubesd_call(
'dom0', 'admin.label.Get', self._name, None)
except qubesadmin.exc.QubesDaemonNoResponseError:
raise AttributeError
raise qubesadmin.exc.QubesPropertyAccessError('label.color')
self._color = qubesd_response.decode()
return self._color

Expand All @@ -63,13 +63,13 @@ def icon(self):

@property
def index(self):
'''color specification as in HTML (``#abcdef``)'''
'''label numeric identifier'''
if self._index is None:
try:
qubesd_response = self.app.qubesd_call(
'dom0', 'admin.label.Index', self._name, None)
except qubesadmin.exc.QubesDaemonNoResponseError:
raise AttributeError
raise qubesadmin.exc.QubesPropertyAccessError('label.index')
self._index = int(qubesd_response.decode())
return self._index

Expand Down
4 changes: 2 additions & 2 deletions qubesadmin/spinner.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class QubesSpinner(AbstractSpinner):
This spinner uses standard ASCII control characters'''
def __init__(self, *args, **kwargs):
super(QubesSpinner, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.hidelen = 0
self.cub1 = '\b'

Expand Down Expand Up @@ -120,7 +120,7 @@ def __init__(self, stream, charset=None):
if charset is None:
charset = ENTERPRISE_CHARSET if self.stream_isatty else '.'

super(QubesSpinnerEnterpriseEdition, self).__init__(stream, charset)
super().__init__(stream, charset)

if self.stream_isatty:
try:
Expand Down
2 changes: 1 addition & 1 deletion qubesadmin/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Tags(object):
# pylint: disable=too-few-public-methods

def __init__(self, vm):
super(Tags, self).__init__()
super().__init__()
self.vm = vm

def remove(self, elem):
Expand Down
26 changes: 12 additions & 14 deletions qubesadmin/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self,
metavar='NAME=VALUE',
required=False,
help='set property to a value'):
super(PropertyAction, self).__init__(option_strings, 'properties',
super().__init__(option_strings, 'properties',
metavar=metavar, default={}, help=help)

def __call__(self, parser, namespace, values, option_string=None):
Expand Down Expand Up @@ -99,7 +99,7 @@ def __init__(self,
if const is not None:
nargs = 0

super(SinglePropertyAction, self).__init__(option_strings, 'properties',
super().__init__(option_strings, 'properties',
metavar=metavar, help=help, default={}, const=const,
nargs=nargs)

Expand Down Expand Up @@ -141,7 +141,7 @@ def __init__(self, option_strings, nargs=1, dest='vmnames', help=None,
nargs, "Passed unexpected value {!s} as {!s} nargs ".format(
nargs, dest))

super(VmNameAction, self).__init__(option_strings, dest=dest, help=help,
super().__init__(option_strings, dest=dest, help=help,
nargs=nargs, **kwargs)

def __call__(self, parser, namespace, values, option_string=None):
Expand Down Expand Up @@ -200,11 +200,11 @@ def __init__(self, option_strings, nargs=1, dest='vmnames', help=None,
raise argparse.ArgumentError(
nargs, "Passed unexpected value {!s} as {!s} nargs ".format(
nargs, dest))
super(RunningVmNameAction, self).__init__(
super().__init__(
option_strings, dest=dest, help=help, nargs=nargs, **kwargs)

def parse_qubes_app(self, parser, namespace):
super(RunningVmNameAction, self).parse_qubes_app(parser, namespace)
super().parse_qubes_app(parser, namespace)
for vm in namespace.domains:
if not vm.is_running():
parser.error_runtime("domain {!r} is not running".format(
Expand All @@ -220,7 +220,7 @@ class VolumeAction(QubesAction):
def __init__(self, help='A pool & volume id combination',
required=True, **kwargs):
# pylint: disable=redefined-builtin
super(VolumeAction, self).__init__(help=help, required=required,
super().__init__(help=help, required=required,
**kwargs)

def __call__(self, parser, namespace, values, option_string=None):
Expand Down Expand Up @@ -261,7 +261,7 @@ class VMVolumeAction(QubesAction):
def __init__(self, help='A pool & volume id combination',
required=True, **kwargs):
# pylint: disable=redefined-builtin
super(VMVolumeAction, self).__init__(help=help, required=required,
super().__init__(help=help, required=required,
**kwargs)

def __call__(self, parser, namespace, values, option_string=None):
Expand Down Expand Up @@ -339,7 +339,7 @@ class QubesArgumentParser(argparse.ArgumentParser):

def __init__(self, vmname_nargs=None, **kwargs):

super(QubesArgumentParser, self).__init__(add_help=False, **kwargs)
super().__init__(add_help=False, **kwargs)

self._vmname_nargs = vmname_nargs

Expand Down Expand Up @@ -370,7 +370,7 @@ def parse_args(self, *args, **kwargs):
# pylint: disable=arguments-differ,signature-differs
# hack for tests
app = kwargs.pop('app', None)
namespace = super(QubesArgumentParser, self).parse_args(*args, **kwargs)
namespace = super().parse_args(*args, **kwargs)

self.set_qubes_verbosity(namespace)
if app is not None:
Expand Down Expand Up @@ -472,8 +472,7 @@ def __init__(self, name, aliases, help):
dest = name
if aliases:
dest += ' (%s)' % ','.join(aliases)
super(AliasedSubParsersAction._AliasedPseudoAction, self).\
__init__(option_strings=[], dest=dest, help=help)
super().__init__(option_strings=[], dest=dest, help=help)

def __call__(self, parser, namespace, values, option_string=None):
pass
Expand All @@ -485,8 +484,7 @@ def add_parser(self, name, **kwargs):
else:
aliases = []

local_parser = super(AliasedSubParsersAction, self).add_parser(
name, **kwargs)
local_parser = super().add_parser(name, **kwargs)

# Make the aliases work.
for alias in aliases:
Expand Down Expand Up @@ -532,7 +530,7 @@ class VmNameGroup(argparse._MutuallyExclusiveGroup):

def __init__(self, container, required, vm_action=VmNameAction, help=None):
# pylint: disable=redefined-builtin
super(VmNameGroup, self).__init__(container, required=required)
super().__init__(container, required=required)
if not help:
help = 'perform the action on all qubes'
self.add_argument('--all', action='store_true', dest='all_domains',
Expand Down
2 changes: 1 addition & 1 deletion qubesadmin/tools/qvm_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __init__(self, help='A backend & device id combination',
required=True, allow_unknown=False, **kwargs):
# pylint: disable=redefined-builtin
self.allow_unknown = allow_unknown
super(DeviceAction, self).__init__(help=help, required=required,
super().__init__(help=help, required=required,
**kwargs)

def __call__(self, parser, namespace, values, option_string=None):
Expand Down
Loading

0 comments on commit e618623

Please sign in to comment.