diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2014-04-29 13:08:19 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2014-04-29 13:08:19 +0200 |
commit | e772fe51ac49b3e00b119f6ab9c819a9f50c3278 (patch) | |
tree | ab103515e455e3993cbfb2efa108fc4cb823f9c8 | |
parent | 03b18258c118e2d5f0d64d3fe53b45a1cbdb3787 (diff) | |
download | pylint-e772fe51ac49b3e00b119f6ab9c819a9f50c3278.tar.gz |
fix explicit check of python script. Closes #219
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | lint.py | 2 | ||||
-rw-r--r-- | test/unittest_lint.py | 13 | ||||
-rw-r--r-- | utils.py | 3 |
4 files changed, 17 insertions, 4 deletions
@@ -20,12 +20,15 @@ ChangeLog for Pylint * Extend the checking for unbalanced-tuple-unpacking and unpacking-non-sequence to instance attribute unpacking as well. + * Fix explicit checking of python script (1.2 regression, #219) + * Restore --init-hook, renamed accidentally into --init-hooks in 1.2.0 (#211) * Add 'indexing-exception' warning, which detects that indexing an exception occurs in Python 2 (behaviour removed in Python 3). + 2014-04-18 -- 1.2.0 * Pass the current python paths to pylint process when invoked via epylint. Fixes BitBucket issue #133. @@ -607,7 +607,7 @@ warning, statement which respectively contain the number of errors / warnings\ # build ast and check modules or packages for descr in self.expand_files(files_or_modules): modname, filepath = descr['name'], descr['path'] - if not self.should_analyze_file(modname, filepath): + if not descr['isarg'] and not self.should_analyze_file(modname, filepath): continue if self.config.files_output: reportfile = 'pylint_%s.%s' % (modname, self.reporter.extension) diff --git a/test/unittest_lint.py b/test/unittest_lint.py index 2b13039..7dd403b 100644 --- a/test/unittest_lint.py +++ b/test/unittest_lint.py @@ -279,8 +279,9 @@ class PyLinterTC(TestCase): self.linter.set_reporter(text.TextReporter()) self.linter.config.files_output = True self.linter.should_analyze_file = lambda *args: False - self.linter.check('os') - self.assertFalse(os.path.exists('pylint_os.txt')) + self.linter.check('logilab') + self.assertTrue(os.path.exists('pylint_logilab.txt')) + self.assertFalse(os.path.exists('pylint_logilab_common.txt')) def test_enable_report(self): self.assertEqual(self.linter.report_is_enabled('RP0001'), True) @@ -385,6 +386,14 @@ class PyLinterTC(TestCase): self.assertRaises(RuntimeError, Run, ['--init-hook', 'raise RuntimeError', '--load-plugins', 'unexistant']) + + def test_analyze_explicit_script(self): + self.linter.set_reporter(TestReporter()) + self.linter.check(self.datapath('ascript')) + self.assertEqual( + ['C: 2: Line too long (175/80)'], + self.linter.reporter.messages) + class ConfigTC(TestCase): def setUp(self): @@ -638,7 +638,7 @@ def expand_modules(files_or_modules, black_list): errors.append({'key': 'fatal', 'mod': modname, 'ex': ex}) continue filepath = normpath(filepath) - result.append({'path': filepath, 'name': modname, + result.append({'path': filepath, 'name': modname, 'isarg': True, 'basepath': filepath, 'basename': modname}) if not (modname.endswith('.__init__') or modname == '__init__') \ and '__init__.py' in filepath: @@ -647,6 +647,7 @@ def expand_modules(files_or_modules, black_list): continue submodname = '.'.join(modpath_from_file(subfilepath)) result.append({'path': subfilepath, 'name': submodname, + 'isarg': False, 'basepath': filepath, 'basename': modname}) return result, errors |