From 79407a8717849bc632977be29e4ee9b727f486d8 Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Sat, 15 Apr 2017 23:48:02 +0200 Subject: [PATCH] =?UTF-8?q?Make=20pylint=20=E2=99=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qubes/core2migration.py | 3 ++- qubes/devices.py | 3 ++- qubes/ext/pci.py | 4 +++- qubes/rngdoc.py | 3 ++- qubes/tests/devices.py | 2 ++ qubes/tools/__init__.py | 9 ++++----- qubes/tools/qubesd.py | 2 +- qubes/tools/qvm_backup_restore.py | 1 - qubes/vm/adminvm.py | 6 +++--- qubes/vm/qubesvm.py | 2 ++ 10 files changed, 21 insertions(+), 14 deletions(-) diff --git a/qubes/core2migration.py b/qubes/core2migration.py index 70c45e6f..2286ad1b 100644 --- a/qubes/core2migration.py +++ b/qubes/core2migration.py @@ -221,7 +221,8 @@ class Core2Qubes(qubes.Qubes): for pcidev in pcidevs: try: dev = self.domains[0].devices['pci'][pcidev] - assignment = qubes.devices.DeviceAssignment(backend_domain=dev.backend_domain, ident=dev.ident) + assignment = qubes.devices.DeviceAssignment( + backend_domain=dev.backend_domain, ident=dev.ident) vm.devices["pci"].attach(assignment) except qubes.exc.QubesException as e: self.log.error("VM {}: {}".format(vm.name, str(e))) diff --git a/qubes/devices.py b/qubes/devices.py index 90c3dd0c..bd5f885d 100644 --- a/qubes/devices.py +++ b/qubes/devices.py @@ -292,7 +292,7 @@ class DeviceInfo(object): ''' Holds all information about a device ''' # pylint: disable=too-few-public-methods def __init__(self, backend_domain, ident, description=None, - frontend_domain=None, options = None, **kwargs): + frontend_domain=None, options=None, **kwargs): #: domain providing this device self.backend_domain = backend_domain #: device identifier (unique for given domain and device type) @@ -308,6 +308,7 @@ class DeviceInfo(object): self.frontend_domain = frontend_domain except AttributeError: pass + self.options = options or dict() self.data = kwargs if hasattr(self, 'regex'): diff --git a/qubes/ext/pci.py b/qubes/ext/pci.py index 416e3bee..3e745195 100644 --- a/qubes/ext/pci.py +++ b/qubes/ext/pci.py @@ -19,6 +19,8 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # +''' Qubes PCI Extensions ''' + import os import re import subprocess @@ -34,7 +36,7 @@ pci_classes = None def load_pci_classes(): - # List of known device classes, subclasses and programming interfaces + ''' List of known device classes, subclasses and programming interfaces. ''' # Syntax: # C class class_name # subclass subclass_name <-- single tab diff --git a/qubes/rngdoc.py b/qubes/rngdoc.py index df7a40bc..f35624d4 100755 --- a/qubes/rngdoc.py +++ b/qubes/rngdoc.py @@ -93,7 +93,7 @@ class Element(object): for xml in self.xml.xpath('''./rng:attribute | ./rng:optional/rng:attribute | ./rng:choice/rng:attribute''', namespaces=self.nsmap): - required = xml.getparent() == self.xml and 'yes' or 'no' + required = 'yes' if xml.getparent() == self.xml else 'no' yield (xml, required) @@ -212,6 +212,7 @@ Quick example, worth thousands lines of specification: if __name__ == '__main__': + # pylint: disable=no-value-for-parameter main(*sys.argv[1:]) # vim: ts=4 sw=4 et diff --git a/qubes/tests/devices.py b/qubes/tests/devices.py index 3f104725..86a3926a 100644 --- a/qubes/tests/devices.py +++ b/qubes/tests/devices.py @@ -26,6 +26,7 @@ import qubes.devices import qubes.tests class TestDevice(qubes.devices.DeviceInfo): + # pylint: disable=too-few-public-methods pass @@ -35,6 +36,7 @@ class TestVMCollection(dict): class TestApp(object): + # pylint: disable=too-few-public-methods def __init__(self): self.domains = TestVMCollection() diff --git a/qubes/tools/__init__.py b/qubes/tools/__init__.py index 4f423f47..f1ee9bc7 100644 --- a/qubes/tools/__init__.py +++ b/qubes/tools/__init__.py @@ -352,8 +352,8 @@ class QubesArgumentParser(argparse.ArgumentParser): self.set_defaults(verbose=1, quiet=0) - def parse_args(self, *args, **kwargs): - namespace = super(QubesArgumentParser, self).parse_args(*args, **kwargs) + def parse_args(self, args=None, namespace=None): + namespace = super(QubesArgumentParser, self).parse_args(args, namespace) if self._want_app and not self._want_app_no_instance: self.set_qubes_verbosity(namespace) @@ -441,9 +441,8 @@ class AliasedSubParsersAction(argparse._SubParsersAction): sup = super(AliasedSubParsersAction._AliasedPseudoAction, self) sup.__init__(option_strings=[], dest=dest, help=help) - def __call__(self, **kwargs): - super(AliasedSubParsersAction._AliasedPseudoAction, self).__call__( - **kwargs) + def __call__(self, parser, namespace, values, option_string=None): + raise NotImplementedError def add_parser(self, name, **kwargs): if 'aliases' in kwargs: diff --git a/qubes/tools/qubesd.py b/qubes/tools/qubesd.py index a624fcc9..4ba9e955 100644 --- a/qubes/tools/qubesd.py +++ b/qubes/tools/qubesd.py @@ -38,7 +38,7 @@ class QubesDaemonProtocol(asyncio.Protocol): print('connection_lost(exc={!r})'.format(exc)) self.untrusted_buffer.close() - def data_received(self, untrusted_data): + def data_received(self, untrusted_data): # pylint: disable=arguments-differ print('data_received(untrusted_data={!r})'.format(untrusted_data)) if self.len_untrusted_buffer + len(untrusted_data) > self.buffer_size: self.app.log.warning('request too long') diff --git a/qubes/tools/qvm_backup_restore.py b/qubes/tools/qvm_backup_restore.py index 88dbf1f4..d8cc87f0 100644 --- a/qubes/tools/qvm_backup_restore.py +++ b/qubes/tools/qvm_backup_restore.py @@ -204,7 +204,6 @@ def main(args=None): "and (if encrypted) decrypt the backup: ") encoding = sys.stdin.encoding or locale.getpreferredencoding() - # pylint: disable=redefined-variable-type passphrase = passphrase.decode(encoding) args.app.log.info("Checking backup content...") diff --git a/qubes/vm/adminvm.py b/qubes/vm/adminvm.py index a571a3de..f1fa10ad 100644 --- a/qubes/vm/adminvm.py +++ b/qubes/vm/adminvm.py @@ -115,8 +115,7 @@ class AdminVM(qubes.vm.qubesvm.QubesVM): try: return self.app.vmm.libvirt_conn.getInfo()[1] except libvirt.libvirtError as e: - self.log.warning( - 'Failed to get memory limit for dom0: {}'.format(e)) + self.log.warning('Failed to get memory limit for dom0: %s', e) return 4096 def verify_files(self): @@ -127,7 +126,8 @@ class AdminVM(qubes.vm.qubesvm.QubesVM): ''' # pylint: disable=no-self-use return True - def start(self, **kwargs): + def start(self, preparing_dvm=False, start_guid=True, notify_function=None, + mem_required=None): '''Always raises an exception. .. seealso: diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 53a3975e..615fb503 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -429,6 +429,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): # CORE2: swallowed uses_default_kernelopts kernelopts = qubes.property('kernelopts', type=str, load_stage=4, default=(lambda self: qubes.config.defaults['kernelopts_pcidevs'] + # pylint: disable=no-member if list(self.devices['pci'].persistent()) else self.template.kernelopts if hasattr(self, 'template') else qubes.config.defaults['kernelopts']), @@ -443,6 +444,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): # XXX shouldn't this go to standalone VM and TemplateVM, and leave here # only plain property? default_user = qubes.property('default_user', type=str, + # pylint: disable=no-member default=(lambda self: self.template.default_user if hasattr(self, 'template') else 'user'), setter=_setter_default_user,