Make pylint happy

- ignore raise-missing-from
- fix super-with-arguments
This commit is contained in:
Marek Marczykowski-Górecki 2020-08-23 02:22:41 +02:00
parent 6b9528316f
commit 1500ed8fcb
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
21 changed files with 67 additions and 68 deletions

View File

@ -22,6 +22,7 @@ disable=
logging-format-interpolation,
missing-docstring,
not-an-iterable,
raise-missing-from,
star-args,
wrong-import-order

View File

@ -543,7 +543,7 @@ class PropertyHolder(qubes.events.Emitter):
continue
propvalues[key] = kwargs.pop(key)
super(PropertyHolder, self).__init__(**kwargs)
super().__init__(**kwargs)
for key, value in propvalues.items():
setattr(self, key, value)

View File

@ -914,7 +914,7 @@ class Qubes(qubes.PropertyHolder):
qubes.config.system_path[
'qubes_store_filename']))
super(Qubes, self).__init__(xml=None, **kwargs)
super().__init__(xml=None, **kwargs)
self.__load_timestamp = None
self.__locked_fh = None

View File

@ -69,7 +69,7 @@ _re_alphanum = re.compile(r'^[A-Za-z0-9-]*$')
class BackupCanceledError(qubes.exc.QubesException):
def __init__(self, msg, tmpdir=None):
super(BackupCanceledError, self).__init__(msg)
super().__init__(msg)
self.tmpdir = tmpdir
@ -124,7 +124,7 @@ class BackupHeader:
class SendWorker:
# pylint: disable=too-few-public-methods
def __init__(self, queue, base_dir, backup_stdout):
super(SendWorker, self).__init__()
super().__init__()
self.queue = queue
self.base_dir = base_dir
self.backup_stdout = backup_stdout
@ -317,7 +317,7 @@ class Backup:
If vms = None, use default list based on vm.include_in_backups property;
exclude_list is always applied
"""
super(Backup, self).__init__()
super().__init__()
#: progress of the backup - bytes handled of the current VM
self.chunk_size = 100 * 1024 * 1024

View File

@ -411,7 +411,7 @@ class DeviceManager(dict):
'''
def __init__(self, vm):
super(DeviceManager, self).__init__()
super().__init__()
self._vm = vm
def __missing__(self, key):
@ -427,7 +427,7 @@ class UnknownDevice(DeviceInfo):
frontend_domain=None):
if description is None:
description = "Unknown device"
super(UnknownDevice, self).__init__(backend_domain, ident, description,
super().__init__(backend_domain, ident, description,
frontend_domain)

View File

@ -102,7 +102,7 @@ class Emitter(metaclass=EmitterMeta):
'''
def __init__(self, *args, **kwargs):
super(Emitter, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
if not hasattr(self, 'events_enabled'):
self.events_enabled = False
self.__handlers__ = collections.defaultdict(set)

View File

@ -29,7 +29,7 @@ class QubesException(Exception):
class QubesVMNotFoundError(QubesException, KeyError):
'''Domain cannot be found in the system'''
def __init__(self, vmname):
super(QubesVMNotFoundError, self).__init__(
super().__init__(
'No such domain: {!r}'.format(vmname))
self.vmname = vmname
@ -41,13 +41,13 @@ class QubesVMNotFoundError(QubesException, KeyError):
class QubesVMError(QubesException):
'''Some problem with domain state.'''
def __init__(self, vm, msg):
super(QubesVMError, self).__init__(msg)
super().__init__(msg)
self.vm = vm
class QubesVMInUseError(QubesVMError):
'''VM is in use, cannot remove.'''
def __init__(self, vm, msg=None):
super(QubesVMInUseError, self).__init__(vm,
super().__init__(vm,
msg or 'Domain is in use: {!r}'.format(vm.name))
class QubesVMNotStartedError(QubesVMError):
@ -57,7 +57,7 @@ class QubesVMNotStartedError(QubesVMError):
(that is, either running or paused).
'''
def __init__(self, vm, msg=None):
super(QubesVMNotStartedError, self).__init__(vm,
super().__init__(vm,
msg or 'Domain is powered off: {!r}'.format(vm.name))
@ -68,7 +68,7 @@ class QubesVMNotRunningError(QubesVMNotStartedError):
halted or paused.
'''
def __init__(self, vm, msg=None):
super(QubesVMNotRunningError, self).__init__(vm,
super().__init__(vm,
msg or 'Domain not running (either powered off or paused): {!r}' \
.format(vm.name))
@ -79,7 +79,7 @@ class QubesVMNotPausedError(QubesVMNotStartedError):
This exception is thrown when machine should be paused, but is not.
'''
def __init__(self, vm, msg=None):
super(QubesVMNotPausedError, self).__init__(vm,
super().__init__(vm,
msg or 'Domain is not paused: {!r}'.format(vm.name))
@ -90,7 +90,7 @@ class QubesVMNotSuspendedError(QubesVMError):
halted or running.
'''
def __init__(self, vm, msg=None):
super(QubesVMNotSuspendedError, self).__init__(vm,
super().__init__(vm,
msg or 'Domain is not suspended: {!r}'.format(vm.name))
@ -101,7 +101,7 @@ class QubesVMNotHaltedError(QubesVMError):
running or paused).
'''
def __init__(self, vm, msg=None):
super(QubesVMNotHaltedError, self).__init__(vm,
super().__init__(vm,
msg or 'Domain is not powered off: {!r}'.format(vm.name))
class QubesVMShutdownTimeoutError(QubesVMError):
@ -109,21 +109,21 @@ class QubesVMShutdownTimeoutError(QubesVMError):
'''
def __init__(self, vm, msg=None):
super(QubesVMShutdownTimeoutError, self).__init__(vm,
super().__init__(vm,
msg or 'Domain shutdown timed out: {!r}'.format(vm.name))
class QubesNoTemplateError(QubesVMError):
'''Cannot start domain, because there is no template'''
def __init__(self, vm, msg=None):
super(QubesNoTemplateError, self).__init__(vm,
super().__init__(vm,
msg or 'Template for the domain {!r} not found'.format(vm.name))
class QubesPoolInUseError(QubesException):
'''VM is in use, cannot remove.'''
def __init__(self, pool, msg=None):
super(QubesPoolInUseError, self).__init__(
super().__init__(
msg or 'Storage pool is in use: {!r}'.format(pool.name))
@ -135,7 +135,7 @@ class QubesPropertyValueError(QubesValueError):
'''Cannot set value of qubes.property, because user-supplied value is wrong.
'''
def __init__(self, holder, prop, value, msg=None):
super(QubesPropertyValueError, self).__init__(
super().__init__(
msg or 'Invalid value {!r} for property {!r} of {!r}'.format(
value, prop.__name__, holder))
self.holder = holder
@ -147,7 +147,7 @@ class QubesNoSuchPropertyError(QubesException, AttributeError):
'''Requested property does not exist
'''
def __init__(self, holder, prop_name, msg=None):
super(QubesNoSuchPropertyError, self).__init__(
super().__init__(
msg or 'Invalid property {!r} of {!s}'.format(
prop_name, holder))
self.holder = holder
@ -157,14 +157,14 @@ class QubesNoSuchPropertyError(QubesException, AttributeError):
class QubesNotImplementedError(QubesException, NotImplementedError):
'''Thrown at user when some feature is not implemented'''
def __init__(self, msg=None):
super(QubesNotImplementedError, self).__init__(
super().__init__(
msg or 'This feature is not available')
class BackupCancelledError(QubesException):
'''Thrown at user when backup was manually cancelled'''
def __init__(self, msg=None):
super(BackupCancelledError, self).__init__(
super().__init__(
msg or 'Backup cancelled')
@ -172,21 +172,21 @@ class BackupAlreadyRunningError(QubesException):
'''Thrown at user when they try to run the same backup twice at
the same time'''
def __init__(self, msg=None):
super(BackupAlreadyRunningError, self).__init__(
super().__init__(
msg or 'Backup already running')
class QubesMemoryError(QubesVMError, MemoryError):
'''Cannot start domain, because not enough memory is available'''
def __init__(self, vm, msg=None):
super(QubesMemoryError, self).__init__(vm,
super().__init__(vm,
msg or 'Not enough memory to start domain {!r}'.format(vm.name))
class QubesFeatureNotFoundError(QubesException, KeyError):
'''Feature not set for a given domain'''
def __init__(self, domain, feature):
super(QubesFeatureNotFoundError, self).__init__(
super().__init__(
'Feature not set for domain {}: {}'.format(domain, feature))
self.feature = feature
self.vm = domain

View File

@ -36,7 +36,7 @@ class JustEvaluateAllowResolution(parser.AllowResolution):
class AdminExtension(qubes.ext.Extension):
def __init__(self):
super(AdminExtension, self).__init__()
super().__init__()
# during tests, __init__() of the extension can be called multiple
# times, because there are multiple Qubes() object instances
if not hasattr(self, 'policy_cache'):

View File

@ -44,7 +44,7 @@ SYSTEM_DISKS_DOM0_KERNEL = SYSTEM_DISKS + ('xvdd',)
class BlockDevice(qubes.devices.DeviceInfo):
def __init__(self, backend_domain, ident):
super(BlockDevice, self).__init__(backend_domain=backend_domain,
super().__init__(backend_domain=backend_domain,
ident=ident)
self._description = None
self._mode = None

View File

@ -140,7 +140,7 @@ class PCIDevice(qubes.devices.DeviceInfo):
assert dev_match
ident = '{bus}_{device}.{function}'.format(**dev_match.groupdict())
super(PCIDevice, self).__init__(backend_domain, ident, None)
super().__init__(backend_domain, ident, None)
# lazy loading
self._description = None
@ -171,7 +171,7 @@ class PCIDevice(qubes.devices.DeviceInfo):
class PCIDeviceExtension(qubes.ext.Extension):
def __init__(self):
super(PCIDeviceExtension, self).__init__()
super().__init__()
# lazy load this
self.pci_classes = {}

View File

@ -63,7 +63,7 @@ class RuleChoice(RuleOption):
# pylint: disable=abstract-method
def __init__(self, untrusted_value):
# preliminary validation
super(RuleChoice, self).__init__(untrusted_value)
super().__init__(untrusted_value)
self.allowed_values = \
[v for k, v in self.__class__.__dict__.items()
if not k.startswith('__') and isinstance(v, str) and
@ -152,7 +152,7 @@ class DstHost(RuleOption):
except socket.error:
raise ValueError('Invalid IP address: ' + untrusted_host)
super(DstHost, self).__init__(value)
super().__init__(value)
@property
def rule(self):
@ -173,7 +173,7 @@ class DstPorts(RuleOption):
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 '-'.join(map(str, self.range)))
@ -187,7 +187,7 @@ class IcmpType(RuleOption):
untrusted_value = int(untrusted_value)
if untrusted_value < 0 or untrusted_value > 255:
raise ValueError('ICMP type out of range')
super(IcmpType, self).__init__(untrusted_value)
super().__init__(untrusted_value)
@property
def rule(self):
@ -204,7 +204,7 @@ class SpecialTarget(RuleChoice):
class Expire(RuleOption):
def __init__(self, untrusted_value):
super(Expire, self).__init__(untrusted_value)
super().__init__(untrusted_value)
self.datetime = datetime.datetime.fromtimestamp(int(untrusted_value))
@property
@ -248,7 +248,7 @@ class Rule(qubes.PropertyHolder):
:param xml: XML element describing rule, or None
:param kwargs: rule elements
'''
super(Rule, self).__init__(xml, **kwargs)
super().__init__(xml, **kwargs)
self.load_properties()
self.events_enabled = True
# validate dependencies

View File

@ -52,7 +52,7 @@ class DBusHandler(logging.Handler):
}
def __init__(self, *args, **kwargs):
super(DBusHandler, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self._notify_object = dbus.SessionBus().get_object(
'org.freedesktop.Notifications', '/org/freedesktop/Notifications')

View File

@ -27,7 +27,7 @@ BUF_SIZE = 409600
class TarSparseInfo(tarfile.TarInfo):
def __init__(self, name="", sparsemap=None):
super(TarSparseInfo, self).__init__(name)
super().__init__(name)
if sparsemap is not None:
self.type = tarfile.REGTYPE
self.sparsemap = sparsemap
@ -65,7 +65,7 @@ class TarSparseInfo(tarfile.TarInfo):
def tobuf(self, format=tarfile.PAX_FORMAT, encoding=tarfile.ENCODING,
errors="strict"):
# pylint: disable=redefined-builtin
header_buf = super(TarSparseInfo, self).tobuf(format, encoding, errors)
header_buf = super().tobuf(format, encoding, errors)
return header_buf + self.sparsemap_buf
def get_sparse_map(input_file):

View File

@ -58,7 +58,7 @@ class PropertyAction(argparse.Action):
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):
@ -90,7 +90,7 @@ class SinglePropertyAction(argparse.Action):
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)
@ -112,7 +112,7 @@ class HelpPropertiesAction(argparse.Action):
default=argparse.SUPPRESS,
help='list all available properties with short descriptions'
' and exit'):
super(HelpPropertiesAction, self).__init__(
super().__init__(
option_strings=option_strings,
dest=dest,
default=default,
@ -165,7 +165,7 @@ class VmNameAction(QubesAction):
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):
@ -215,11 +215,11 @@ class RunningVmNameAction(VmNameAction):
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(
@ -235,7 +235,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):
@ -319,7 +319,7 @@ class QubesArgumentParser(argparse.ArgumentParser):
def __init__(self, want_app=True, want_app_no_instance=False,
want_force_root=False, vmname_nargs=None, **kwargs):
super(QubesArgumentParser, self).__init__(**kwargs)
super().__init__(**kwargs)
self._want_app = want_app
self._want_app_no_instance = want_app_no_instance
@ -352,7 +352,7 @@ class QubesArgumentParser(argparse.ArgumentParser):
self.set_defaults(verbose=1, quiet=0)
def parse_args(self, args=None, namespace=None):
namespace = super(QubesArgumentParser, self).parse_args(args, namespace)
namespace = super().parse_args(args, namespace)
if self._want_app and not self._want_app_no_instance:
self.set_qubes_verbosity(namespace)
@ -437,8 +437,7 @@ class AliasedSubParsersAction(argparse._SubParsersAction):
dest = name
if aliases:
dest += ' (%s)' % ','.join(aliases)
sup = super(AliasedSubParsersAction._AliasedPseudoAction, self)
sup.__init__(option_strings=[], dest=dest, help=help)
super().__init__(option_strings=[], dest=dest, help=help)
def __call__(self, parser, namespace, values, option_string=None):
raise NotImplementedError
@ -450,8 +449,7 @@ class AliasedSubParsersAction(argparse._SubParsersAction):
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:
@ -497,7 +495,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',

View File

@ -103,7 +103,7 @@ class Tags(set):
# using official documentation, but use only our (overloaded) methods.
#
def __init__(self, vm, seq=()):
super(Tags, self).__init__()
super().__init__()
self.vm = vm
self.update(seq)
@ -148,12 +148,12 @@ class Tags(set):
raise ValueError('Invalid character in tag')
if elem in self:
return
super(Tags, self).add(elem)
super().add(elem)
self.vm.fire_event('domain-tag-add:' + elem, tag=elem)
def remove(self, elem):
'''Remove a tag'''
super(Tags, self).remove(elem)
super().remove(elem)
self.vm.fire_event('domain-tag-delete:' + elem, tag=elem)
#
@ -212,7 +212,7 @@ class BaseVM(qubes.PropertyHolder):
#: mother :py:class:`qubes.Qubes` object
self.app = app
super(BaseVM, self).__init__(xml, **kwargs)
super().__init__(xml, **kwargs)
#: dictionary of features of this qube
self.features = qubes.features.Features(self, features)
@ -454,7 +454,7 @@ class VMProperty(qubes.property):
raise TypeError(
"'vmclass' should specify a subclass of qubes.vm.BaseVM")
super(VMProperty, self).__init__(name,
super().__init__(name,
saver=(lambda self_, prop, value:
self._none_value if value is None else value.name),
**kwargs)
@ -470,7 +470,7 @@ class VMProperty(qubes.property):
value = None
if value is None:
if self.allow_none:
super(VMProperty, self).__set__(instance, value)
super().__set__(instance, value)
return
raise ValueError(
'Property {!r} does not allow setting to {!r}'.format(
@ -489,7 +489,7 @@ class VMProperty(qubes.property):
vm.__class__.__name__,
self.vmclass.__name__))
super(VMProperty, self).__set__(instance, vm)
super().__set__(instance, vm)
def sanitize(self, *, untrusted_newvalue):
try:

View File

@ -92,7 +92,7 @@ class AppVM(qubes.vm.mix.dvmtemplate.DVMTemplateMixin,
if 'vid' in self.volume_config[name]:
del self.volume_config[name]['vid']
super(AppVM, self).__init__(app, xml, **kwargs)
super().__init__(app, xml, **kwargs)
@qubes.events.handler('domain-load')
def on_domain_loaded(self, event):

View File

@ -122,7 +122,7 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
and 'pool' in config:
self.volume_config[name]['pool'] = config['pool']
super(DispVM, self).__init__(app, xml, *args, **kwargs)
super().__init__(app, xml, *args, **kwargs)
if xml is None:
# by default inherit properties from the DispVM template
@ -229,7 +229,7 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
'template for DispVM ({}) needs to have '
'template_for_dispvms=True'.format(self.template.name))
yield from super(DispVM, self).start(**kwargs)
yield from super().start(**kwargs)
except:
# Cleanup also on failed startup
yield from self._auto_cleanup()

View File

@ -237,7 +237,7 @@ class NetVMMixin(qubes.events.Emitter):
def __init__(self, *args, **kwargs):
self._firewall = None
super(NetVMMixin, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
@qubes.events.handler('domain-load')
def on_domain_load_netvm_loop_check(self, event):

View File

@ -864,7 +864,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
kwargs['virt_mode'] = 'pv'
node_hvm.getparent().remove(node_hvm)
super(QubesVM, self).__init__(app, xml, **kwargs)
super().__init__(app, xml, **kwargs)
if volume_config is None:
volume_config = {}
@ -950,7 +950,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
def __xml__(self):
# pylint: disable=no-member
element = super(QubesVM, self).__xml__()
element = super().__xml__()
# pylint: enable=no-member
if hasattr(self, 'volumes'):

View File

@ -59,4 +59,4 @@ class StandaloneVM(qubes.vm.mix.dvmtemplate.DVMTemplateMixin,
'rw': False,
}
}
super(StandaloneVM, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

View File

@ -84,7 +84,7 @@ class TemplateVM(QubesVM):
'rw': False
}
}
super(TemplateVM, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
@qubes.events.handler('property-set:default_user',
'property-set:kernel',