From 0c7884d1708d4ca554393e0be08384d1f62f4c21 Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Fri, 9 Dec 2016 08:43:14 +0100 Subject: [PATCH] [all] pylint refinements Improve code by bringing up the pylint score a bit. see #23 --- bumblebee/engine.py | 6 +++--- bumblebee/store.py | 3 +++ tests/modules/test_modules.py | 7 +++---- tests/test_module.py | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bumblebee/engine.py b/bumblebee/engine.py index 99cea34..ca4bb55 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -7,7 +7,7 @@ import importlib import bumblebee.error import bumblebee.modules -def modules(): +def all_modules(): """Return a list of available modules""" result = [] path = os.path.dirname(bumblebee.modules.__file__) @@ -28,7 +28,7 @@ class Module(object): def __init__(self, engine, config={}, widgets=[]): self.name = self.__module__.split(".")[-1] self._config = config - if not "name" in self._config: + if "name" not in self._config: self._config["name"] = self.name self._widgets = [] if widgets: @@ -68,7 +68,7 @@ class Engine(object): def load_module(self, module_name, config_name=None): """Load specified module and return it as object""" - if config_name == None: + if config_name is None: config_name = module_name try: module = importlib.import_module("bumblebee.modules.{}".format(module_name)) diff --git a/bumblebee/store.py b/bumblebee/store.py index 9492c1d..8fac71b 100644 --- a/bumblebee/store.py +++ b/bumblebee/store.py @@ -6,13 +6,16 @@ this module """ class Store(object): + """Interface for storing and retrieving simple values""" def __init__(self): self._data = {} def set(self, key, value): + """Set 'key' to 'value', overwriting 'key' if it exists already""" self._data[key] = value def get(self, key, default=None): + """Return the current value of 'key', or 'default' if 'key' is not set""" return self._data.get(key, default) # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/tests/modules/test_modules.py b/tests/modules/test_modules.py index d08e783..baa6233 100644 --- a/tests/modules/test_modules.py +++ b/tests/modules/test_modules.py @@ -3,8 +3,7 @@ import unittest import importlib -from bumblebee.modules.cpu import Module -from bumblebee.engine import modules +from bumblebee.engine import all_modules from bumblebee.config import Config from tests.util import assertWidgetAttributes, MockEngine @@ -13,9 +12,9 @@ class TestGenericModules(unittest.TestCase): engine = MockEngine() config = Config() self.objects = {} - for mod in modules(): + for mod in all_modules(): cls = importlib.import_module("bumblebee.modules.{}".format(mod["name"])) - self.objects[mod["name"]] = getattr(cls, "Module")(engine, { "config": config }) + self.objects[mod["name"]] = getattr(cls, "Module")(engine, {"config": config}) def test_widgets(self): for mod in self.objects: diff --git a/tests/test_module.py b/tests/test_module.py index 44a39af..0cc95ad 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -19,7 +19,7 @@ class TestModule(unittest.TestCase): self.anyConfigName = "cfg" self.anotherConfigName = "cfg2" self.anyModule = Module(engine=None, widgets=self.widget, config={ - "name": self.anyConfigName, "config": self.config + "name": self.anyConfigName, "config": self.config }) self.anotherModule = Module(engine=None, widgets=self.widget, config={ "name": self.anotherConfigName, "config": self.config