From 5e742bf814ebf3ddb0ebc9f82880c5b156b584c4 Mon Sep 17 00:00:00 2001 From: "Michael A. Smith" Date: Fri, 3 Aug 2018 09:41:34 -0400 Subject: [PATCH 1/3] Fix Lint Errors with Specific Exceptions --- setup.py | 2 +- tests/important/test_main.py | 4 ++-- tests/important/test_parse.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 5aaceef..7d51540 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ try: from setuptools import setup -except: +except ImportError: from distutils.core import setup with open('README.rst') as fh: diff --git a/tests/important/test_main.py b/tests/important/test_main.py index 9c6042b..4a39689 100644 --- a/tests/important/test_main.py +++ b/tests/important/test_main.py @@ -15,10 +15,10 @@ try: from importlib import reload # Python 3.4+ -except: +except ImportError: try: from imp import reload # Python 3.3 - except: + except ImportError: pass # Python 2.7 provides reload built in diff --git a/tests/important/test_parse.py b/tests/important/test_parse.py index e9ff8a0..22c534f 100644 --- a/tests/important/test_parse.py +++ b/tests/important/test_parse.py @@ -15,7 +15,7 @@ try: from unittest.mock import Mock -except: +except ImportError: from mock import Mock From b331d4f0c918af5a290884f1f62901e0c6e2f9f2 Mon Sep 17 00:00:00 2001 From: "Michael A. Smith" Date: Fri, 3 Aug 2018 09:51:12 -0400 Subject: [PATCH 2/3] Fix PyLint no-else-return Complaint --- important/__main__.py | 3 +-- important/parse.py | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/important/__main__.py b/important/__main__.py index 6e2288f..defc6fd 100644 --- a/important/__main__.py +++ b/important/__main__.py @@ -30,8 +30,7 @@ def split(key_value): if key_value[0] in ('sourcecode',): return key_value - else: - return key_value[0], key_value[1].split() + return key_value[0], key_value[1].split() CONTEXT_SETTINGS['default_map'] = \ dict(map(split, CONFIG.items('important'))) diff --git a/important/parse.py b/important/parse.py index 093fbc5..250557f 100644 --- a/important/parse.py +++ b/important/parse.py @@ -161,9 +161,8 @@ def is_top_level_file(filepath): if provides: return provides - else: - module_name = requirement_name.split('.')[0] - if module_name not in ALL_MODULES: - LOGGER.warning("Cannot find install location of '%s'; please \ + module_name = requirement_name.split('.')[0] + if module_name not in ALL_MODULES: + LOGGER.warning("Cannot find install location of '%s'; please \ install this package for more accurate name resolution", requirement_name) - return provides if provides else set([requirement_name]) + return provides if provides else set([requirement_name]) From a64bfd86ba82b92dfd8e7602330d855538bb2b6e Mon Sep 17 00:00:00 2001 From: "Michael A. Smith" Date: Fri, 3 Aug 2018 09:58:05 -0400 Subject: [PATCH 3/3] Fix Pylint consider-using-set-comprehension Complaint --- important/parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/important/parse.py b/important/parse.py index 250557f..314a380 100644 --- a/important/parse.py +++ b/important/parse.py @@ -156,8 +156,8 @@ def is_top_level_file(filepath): provides |= set(folders) # Handle modules that are installed as .py files in site-packages top_level_files = filter(is_top_level_file, result['files']) - provides |= set([os.path.splitext(filename)[0] - for filename in top_level_files]) + provides |= {os.path.splitext(filename)[0] + for filename in top_level_files} if provides: return provides