vtrefny / rpms / pylint

Forked from rpms/pylint 4 years ago
Clone
Blob Blame History Raw
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1398769699 -7200
# Node ID a36dec3e73db2e3546f2e29326048bd582dc08f6
# Parent  bba3891c971f7eac2558cdd12c19ea9cd5a0e5e2
fix explicit check of python script. Closes #219

diff --git a/lint.py b/lint.py
--- a/lint.py
+++ b/lint.py
@@ -607,7 +607,7 @@
         # 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
--- a/test/unittest_lint.py
+++ b/test/unittest_lint.py
@@ -279,8 +279,9 @@
         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 @@
          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):
diff --git a/utils.py b/utils.py
--- a/utils.py
+++ b/utils.py
@@ -638,7 +638,7 @@
                 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 @@
                     continue
                 submodname = '.'.join(modpath_from_file(subfilepath))
                 result.append({'path': subfilepath, 'name': submodname,
+                               'isarg': False,
                                'basepath': filepath, 'basename': modname})
     return result, errors