diff options
author | Michal Nowikowski <godfryd@gmail.com> | 2015-01-14 20:33:43 +0100 |
---|---|---|
committer | Michal Nowikowski <godfryd@gmail.com> | 2015-01-14 20:33:43 +0100 |
commit | bf210b9ad1345b5157179f2a2143e10ba8742c8e (patch) | |
tree | 3818ec2f964d291f20cd46aa26b038cbc6348108 | |
parent | 74b54dfb63862b8821f1438bbffd5ec8f10a7582 (diff) | |
parent | 8af554b029bc4fa18dbc89965b7440e1df5a3e95 (diff) | |
download | pylint-fix-374.tar.gz |
mergefix-374
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | checkers/classes.py | 12 | ||||
-rw-r--r-- | checkers/stdlib.py | 2 | ||||
-rw-r--r-- | doc/make.bat | 190 | ||||
-rw-r--r-- | doc/run.rst | 5 | ||||
-rw-r--r-- | gui.py | 37 | ||||
-rw-r--r-- | setup.py | 28 | ||||
-rw-r--r-- | test/functional/redundant_unittest_assert.py | 8 | ||||
-rw-r--r-- | test/messages/func_interfaces.txt | 2 | ||||
-rw-r--r-- | test/messages/func_w0205.txt | 2 |
10 files changed, 264 insertions, 26 deletions
@@ -34,6 +34,10 @@ ChangeLog for Pylint * Add a new JSON reporter, usable through -f flag. + * Add the method names for the 'signature-differs' and 'argument-differs' + warnings. Closes issue #433. + + * Don't compile test files when installing. 2014-11-23 -- 1.4.0 diff --git a/checkers/classes.py b/checkers/classes.py index 7b216fe..1a10c35 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -179,11 +179,11 @@ MSGS = { 'missing-interface-method', 'Used when a method declared in an interface is missing from a \ class implementing this interface'), - 'W0221': ('Arguments number differs from %s method', + 'W0221': ('Arguments number differs from %s %r method', 'arguments-differ', 'Used when a method has a different number of arguments than in \ the implemented interface or in an overridden method.'), - 'W0222': ('Signature differs from %s method', + 'W0222': ('Signature differs from %s %r method', 'signature-differs', 'Used when a method signature is different than in the \ implemented interface or in an overridden method.'), @@ -939,9 +939,13 @@ a metaclass class method.'} if is_attr_private(method1.name): return if len(method1.args.args) != len(refmethod.args.args): - self.add_message('arguments-differ', args=class_type, node=method1) + self.add_message('arguments-differ', + args=(class_type, method1.name), + node=method1) elif len(method1.args.defaults) < len(refmethod.args.defaults): - self.add_message('signature-differs', args=class_type, node=method1) + self.add_message('signature-differs', + args=(class_type, method1.name), + node=method1) def is_first_attr(self, node): """Check that attribute lookup name use first attribute variable name diff --git a/checkers/stdlib.py b/checkers/stdlib.py index 216d640..b6b8026 100644 --- a/checkers/stdlib.py +++ b/checkers/stdlib.py @@ -134,7 +134,7 @@ class StdlibChecker(BaseChecker): def _check_redundant_assert(self, node, infer): if (isinstance(infer, astroid.BoundMethod) and - isinstance(node.args[0], astroid.Const) and + node.args and isinstance(node.args[0], astroid.Const) and infer.name in ['assertTrue', 'assertFalse']): self.add_message('redundant-unittest-assert', args=(infer.name, node.args[0].value, ), diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 0000000..9482679 --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,190 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^<target^>` where ^<target^> is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\a.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\a.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end diff --git a/doc/run.rst b/doc/run.rst index 418e915..7b95448 100644 --- a/doc/run.rst +++ b/doc/run.rst @@ -121,9 +121,10 @@ configuration. Other useful global options include: ---ignore=file Add <file> (may be a directory) to the black +--ignore=<file[,file]> Add <file> (may be a directory) to the black list. It should be a base name, not a path. - You may set this option multiple times. + Multiple entries can be given, separated by + comma. --persistent=y_or_n Pickle collected data for later comparisons. --output-format=<format> Select output format (text, html, custom). --msg-template=<template> Modifiy text output message template. @@ -25,7 +25,7 @@ import six from six.moves.tkinter import ( Tk, Frame, Listbox, Entry, Label, Button, Scrollbar, - Checkbutton, Radiobutton, IntVar, StringVar, + Checkbutton, Radiobutton, IntVar, StringVar, PanedWindow, TOP, LEFT, RIGHT, BOTTOM, END, X, Y, BOTH, SUNKEN, W, HORIZONTAL, DISABLED, NORMAL, W, ) @@ -150,23 +150,34 @@ class LintGui(object): def init_gui(self): """init helper""" + + window = PanedWindow(self.root, orient="vertical") + window.pack(side=TOP, fill=BOTH, expand=True) + + top_pane = Frame(window) + window.add(top_pane) + mid_pane = Frame(window) + window.add(mid_pane) + bottom_pane = Frame(window) + window.add(bottom_pane) + #setting up frames - top_frame = Frame(self.root) - mid_frame = Frame(self.root) - radio_frame = Frame(self.root) - res_frame = Frame(self.root) - msg_frame = Frame(self.root) - check_frame = Frame(self.root) - history_frame = Frame(self.root) - btn_frame = Frame(self.root) - rating_frame = Frame(self.root) + top_frame = Frame(top_pane) + mid_frame = Frame(top_pane) + history_frame = Frame(top_pane) + radio_frame = Frame(mid_pane) + rating_frame = Frame(mid_pane) + res_frame = Frame(mid_pane) + check_frame = Frame(bottom_pane) + msg_frame = Frame(bottom_pane) + btn_frame = Frame(bottom_pane) top_frame.pack(side=TOP, fill=X) mid_frame.pack(side=TOP, fill=X) history_frame.pack(side=TOP, fill=BOTH, expand=True) - radio_frame.pack(side=TOP, fill=BOTH, expand=True) - rating_frame.pack(side=TOP, fill=BOTH, expand=True) + radio_frame.pack(side=TOP, fill=X) + rating_frame.pack(side=TOP, fill=X) res_frame.pack(side=TOP, fill=BOTH, expand=True) - check_frame.pack(side=TOP, fill=BOTH, expand=True) + check_frame.pack(side=TOP, fill=X) msg_frame.pack(side=TOP, fill=BOTH, expand=True) btn_frame.pack(side=TOP, fill=X) @@ -32,12 +32,14 @@ try: if os.environ.get('NO_SETUPTOOLS'): raise ImportError() from setuptools import setup + from setuptools.command import easy_install as easy_install_lib from setuptools.command import install_lib USE_SETUPTOOLS = 1 except ImportError: from distutils.core import setup from distutils.command import install_lib USE_SETUPTOOLS = 0 + easy_install_lib = None from distutils.command.build_py import build_py @@ -97,6 +99,11 @@ except ImportError: pass ''' +def _filter_tests(files): + testdir = join('pylint', 'test') + return [f for f in files if testdir not in f] + + class MyInstallLib(install_lib.install_lib): """extend install_lib command to handle package __init__.py and include_dirs variable if necessary @@ -138,10 +145,20 @@ class MyInstallLib(install_lib.install_lib): # files, some of them being syntactically wrong by design, and this scares # the end-user def byte_compile(self, files): - testdir = join('pylint', 'test') - files = [f for f in files if testdir not in f] + files = _filter_tests(files) install_lib.install_lib.byte_compile(self, files) + +if easy_install_lib: + class easy_install(easy_install_lib.easy_install): + # override this since pip/easy_install attempt to byte compile + # test data files, some of them being syntactically wrong by design, + # and this scares the end-user + def byte_compile(self, files): + files = _filter_tests(files) + easy_install_lib.easy_install.byte_compile(self, files) + + def install(**kwargs): """setup entry point""" if USE_SETUPTOOLS: @@ -171,6 +188,10 @@ def install(**kwargs): 'symilar = pylint:run_symilar', ]} kwargs['packages'] = packages + cmdclass = {'install_lib': MyInstallLib, + 'build_py': build_py} + if easy_install_lib: + cmdclass['easy_install'] = easy_install return setup(name=distname, version=version, license=license, @@ -183,8 +204,7 @@ def install(**kwargs): classifiers=classifiers, data_files=data_files, ext_modules=ext_modules, - cmdclass={'install_lib': MyInstallLib, - 'build_py': build_py}, + cmdclass=cmdclass, **kwargs) if __name__ == '__main__': diff --git a/test/functional/redundant_unittest_assert.py b/test/functional/redundant_unittest_assert.py index 4628824..2eb73e3 100644 --- a/test/functional/redundant_unittest_assert.py +++ b/test/functional/redundant_unittest_assert.py @@ -28,3 +28,11 @@ class Tests(unittest.TestCase): self.assertTrue('should be' in some_var, some_var) self.assertTrue(some_var, some_var) + + +@unittest.skip("don't run this") +class RegressionWithArgs(unittest.TestCase): + '''Don't fail if the bound method doesn't have arguments.''' + + def test(self): + self.run() diff --git a/test/messages/func_interfaces.txt b/test/messages/func_interfaces.txt index 3b444d7..a4cd21d 100644 --- a/test/messages/func_interfaces.txt +++ b/test/messages/func_interfaces.txt @@ -3,4 +3,4 @@ E: 77:InterfaceCantBeFound: Undefined variable 'undefined' E: 88:InterfaceCanNowBeFound: Missing method 'troc' from IMachin interface E: 88:InterfaceCanNowBeFound: Missing method 'truc' from IMachin interface F: 77:InterfaceCantBeFound: failed to resolve interfaces implemented by InterfaceCantBeFound (undefined) -W: 71:BadArgument.troc: Arguments number differs from IMachin interface method +W: 71:BadArgument.troc: Arguments number differs from IMachin interface 'troc' method diff --git a/test/messages/func_w0205.txt b/test/messages/func_w0205.txt index 4b36dab..83ac5de 100644 --- a/test/messages/func_w0205.txt +++ b/test/messages/func_w0205.txt @@ -1,2 +1,2 @@ -W: 22:Cdef.abcd: Signature differs from overridden method +W: 22:Cdef.abcd: Signature differs from overridden 'abcd' method |