|
|
a13bbd4 |
# HG changeset patch
|
|
|
a13bbd4 |
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
|
|
|
a13bbd4 |
# Date 1398769699 -7200
|
|
|
a13bbd4 |
# Node ID a36dec3e73db2e3546f2e29326048bd582dc08f6
|
|
|
a13bbd4 |
# Parent bba3891c971f7eac2558cdd12c19ea9cd5a0e5e2
|
|
|
a13bbd4 |
fix explicit check of python script. Closes #219
|
|
|
a13bbd4 |
|
|
|
a13bbd4 |
diff --git a/lint.py b/lint.py
|
|
|
a13bbd4 |
--- a/lint.py
|
|
|
a13bbd4 |
+++ b/lint.py
|
|
|
a13bbd4 |
@@ -607,7 +607,7 @@
|
|
|
a13bbd4 |
# build ast and check modules or packages
|
|
|
a13bbd4 |
for descr in self.expand_files(files_or_modules):
|
|
|
a13bbd4 |
modname, filepath = descr['name'], descr['path']
|
|
|
a13bbd4 |
- if not self.should_analyze_file(modname, filepath):
|
|
|
a13bbd4 |
+ if not descr['isarg'] and not self.should_analyze_file(modname, filepath):
|
|
|
a13bbd4 |
continue
|
|
|
a13bbd4 |
if self.config.files_output:
|
|
|
a13bbd4 |
reportfile = 'pylint_%s.%s' % (modname, self.reporter.extension)
|
|
|
a13bbd4 |
diff --git a/test/unittest_lint.py b/test/unittest_lint.py
|
|
|
a13bbd4 |
--- a/test/unittest_lint.py
|
|
|
a13bbd4 |
+++ b/test/unittest_lint.py
|
|
|
a13bbd4 |
@@ -279,8 +279,9 @@
|
|
|
a13bbd4 |
self.linter.set_reporter(text.TextReporter())
|
|
|
a13bbd4 |
self.linter.config.files_output = True
|
|
|
a13bbd4 |
self.linter.should_analyze_file = lambda *args: False
|
|
|
a13bbd4 |
- self.linter.check('os')
|
|
|
a13bbd4 |
- self.assertFalse(os.path.exists('pylint_os.txt'))
|
|
|
a13bbd4 |
+ self.linter.check('logilab')
|
|
|
a13bbd4 |
+ self.assertTrue(os.path.exists('pylint_logilab.txt'))
|
|
|
a13bbd4 |
+ self.assertFalse(os.path.exists('pylint_logilab_common.txt'))
|
|
|
a13bbd4 |
|
|
|
a13bbd4 |
def test_enable_report(self):
|
|
|
a13bbd4 |
self.assertEqual(self.linter.report_is_enabled('RP0001'), True)
|
|
|
a13bbd4 |
@@ -385,6 +386,14 @@
|
|
|
a13bbd4 |
self.assertRaises(RuntimeError,
|
|
|
a13bbd4 |
Run, ['--init-hook', 'raise RuntimeError', '--load-plugins', 'unexistant'])
|
|
|
a13bbd4 |
|
|
|
a13bbd4 |
+
|
|
|
a13bbd4 |
+ def test_analyze_explicit_script(self):
|
|
|
a13bbd4 |
+ self.linter.set_reporter(TestReporter())
|
|
|
a13bbd4 |
+ self.linter.check(self.datapath('ascript'))
|
|
|
a13bbd4 |
+ self.assertEqual(
|
|
|
a13bbd4 |
+ ['C: 2: Line too long (175/80)'],
|
|
|
a13bbd4 |
+ self.linter.reporter.messages)
|
|
|
a13bbd4 |
+
|
|
|
a13bbd4 |
class ConfigTC(TestCase):
|
|
|
a13bbd4 |
|
|
|
a13bbd4 |
def setUp(self):
|
|
|
a13bbd4 |
diff --git a/utils.py b/utils.py
|
|
|
a13bbd4 |
--- a/utils.py
|
|
|
a13bbd4 |
+++ b/utils.py
|
|
|
a13bbd4 |
@@ -638,7 +638,7 @@
|
|
|
a13bbd4 |
errors.append({'key': 'fatal', 'mod': modname, 'ex': ex})
|
|
|
a13bbd4 |
continue
|
|
|
a13bbd4 |
filepath = normpath(filepath)
|
|
|
a13bbd4 |
- result.append({'path': filepath, 'name': modname,
|
|
|
a13bbd4 |
+ result.append({'path': filepath, 'name': modname, 'isarg': True,
|
|
|
a13bbd4 |
'basepath': filepath, 'basename': modname})
|
|
|
a13bbd4 |
if not (modname.endswith('.__init__') or modname == '__init__') \
|
|
|
a13bbd4 |
and '__init__.py' in filepath:
|
|
|
a13bbd4 |
@@ -647,6 +647,7 @@
|
|
|
a13bbd4 |
continue
|
|
|
a13bbd4 |
submodname = '.'.join(modpath_from_file(subfilepath))
|
|
|
a13bbd4 |
result.append({'path': subfilepath, 'name': submodname,
|
|
|
a13bbd4 |
+ 'isarg': False,
|
|
|
a13bbd4 |
'basepath': filepath, 'basename': modname})
|
|
|
a13bbd4 |
return result, errors
|
|
|
a13bbd4 |
|