Skip to content

Commit

Permalink
Some fixes for new PyLint
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Apr 15, 2017
1 parent 64ed767 commit 44be1dc
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 29 deletions.
8 changes: 4 additions & 4 deletions platformio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ def list_commands(self, ctx):
cmds.sort()
return cmds

def get_command(self, ctx, name):
def get_command(self, ctx, cmd_name):
mod = None
try:
mod = __import__("platformio.commands." + name, None, None,
mod = __import__("platformio.commands." + cmd_name, None, None,
["cli"])
except ImportError:
try:
return self._handle_obsolate_command(name)
return self._handle_obsolate_command(cmd_name)
except AttributeError:
raise click.UsageError('No such command "%s"' % name, ctx)
raise click.UsageError('No such command "%s"' % cmd_name, ctx)
return mod.cli

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions platformio/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def __enter__(self):
found = True
if isfile(path):
remove(path)
if not len(listdir(dirname(path))):
if not listdir(dirname(path)):
util.rmtree_(dirname(path))

if found and self._lock_dbindex():
Expand Down Expand Up @@ -228,7 +228,7 @@ def set(self, key, data, valid):
if not isdir(dirname(cache_path)):
os.makedirs(dirname(cache_path))
with open(cache_path, "wb") as fp:
if isinstance(data, dict) or isinstance(data, list):
if isinstance(data, (dict, list)):
json.dump(data, fp)
else:
fp.write(str(data))
Expand Down
3 changes: 1 addition & 2 deletions platformio/builder/tools/piomisc.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ def _lookup_in_ldpath(script):
def VerboseAction(_, act, actstr):
if int(ARGUMENTS.get("PIOVERBOSE", 0)):
return act
else:
return Action(act, actstr)
return Action(act, actstr)


def PioClean(env, clean_dir):
Expand Down
2 changes: 1 addition & 1 deletion platformio/builder/tools/platformio.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _append_build_item(items, item, src_dir):

src_dir = env.subst(src_dir)
src_filter = src_filter or SRC_FILTER_DEFAULT
if isinstance(src_filter, list) or isinstance(src_filter, tuple):
if isinstance(src_filter, (list, tuple)):
src_filter = " ".join(src_filter)

matches = set()
Expand Down
10 changes: 5 additions & 5 deletions platformio/commands/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,14 @@ def lib_builtin(storage, json_output):
if json_output:
return click.echo(json.dumps(items))

for storage in items:
if not storage['items']:
for storage_ in items:
if not storage_['items']:
continue
click.secho(storage['name'], fg="green")
click.echo("*" * len(storage['name']))
click.secho(storage_['name'], fg="green")
click.echo("*" * len(storage_['name']))
click.echo()

for item in sorted(storage['items'], key=lambda i: i['name']):
for item in sorted(storage_['items'], key=lambda i: i['name']):
print_lib_item(item)


Expand Down
3 changes: 1 addition & 2 deletions platformio/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class PlatformioException(Exception):
def __str__(self): # pragma: no cover
if self.MESSAGE:
return self.MESSAGE.format(*self.args)
else:
return Exception.__str__(self)
return Exception.__str__(self)


class ReturnErrorCode(PlatformioException):
Expand Down
3 changes: 1 addition & 2 deletions platformio/managers/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def next(self):

if self.package in manifest:
return manifest[self.package]
else:
return self.next()
return self.next()


class PkgRepoMixin(object):
Expand Down
6 changes: 2 additions & 4 deletions platformio/managers/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def install(self,
skip_default_package=False,
trigger_event=True,
silent=False,
**_): # pylint: disable=too-many-arguments
**_): # pylint: disable=too-many-arguments, arguments-differ
platform_dir = BasePkgManager.install(
self, name, requirements, silent=silent)
p = PlatformFactory.newPlatform(platform_dir)
Expand Down Expand Up @@ -305,9 +305,7 @@ def get_package_dir(self, name):
version = self.packages[name].get("version", "")
if self.is_valid_requirements(version):
return self.pm.get_package_dir(name, version)
else:
return self.pm.get_package_dir(*self._parse_pkg_input(name,
version))
return self.pm.get_package_dir(*self._parse_pkg_input(name, version))

def get_package_version(self, name):
pkg_dir = self.get_package_dir(name)
Expand Down
9 changes: 4 additions & 5 deletions platformio/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ProjectConfig(ConfigParser):

VARTPL_RE = re.compile(r"\$\{([^\.\}]+)\.([^\}]+)\}")

def items(self, section, **_):
def items(self, section, **_): # pylint: disable=arguments-differ
items = []
for option in ConfigParser.options(self, section):
items.append((option, self.get(section, option)))
Expand Down Expand Up @@ -130,10 +130,9 @@ def __call__(self, *args):
return self.func(*args)
if args in self.cache:
return self.cache[args]
else:
value = self.func(*args)
self.cache[args] = value
return value
value = self.func(*args)
self.cache[args] = value
return value

def __repr__(self):
'''Return the function's docstring.'''
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ usedevelop = True
deps =
isort
flake8
yapf
yapf<0.16
pylint
pytest
show
commands = python --version

[testenv:docs]
Expand Down

0 comments on commit 44be1dc

Please sign in to comment.