Skip to content

Commit

Permalink
fix explicit check of python script. Closes #219
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Thénault committed Apr 29, 2014
1 parent 78a3f34 commit fac0b37
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def check(self, files_or_modules):
# 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)
Expand Down
13 changes: 11 additions & 2 deletions test/unittest_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ def test_lint_should_analyze_file(self):
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)
Expand Down Expand Up @@ -385,6 +386,14 @@ def test_init_hooks_called_before_load_plugins(self):
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):
Expand Down
3 changes: 2 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down

0 comments on commit fac0b37

Please sign in to comment.