flake8-2.1.0/0000755000175000001440000000000012233022416013625 5ustar icordascusers00000000000000flake8-2.1.0/CONTRIBUTORS.txt0000644000175000001440000000055612161467632016346 0ustar icordascusers00000000000000Project created by Tarek Ziadé. Contributors (by order of appearance) : - Tamás Gulácsi - Nicolas Dumazet - Stefan Scherfke - Chris Adams - Ben Bass - Ask Solem - Steven Kryskalla - Gustavo Picon - Jannis Leidel - Miki Tebeka - David Cramer - Peter Teichman - Ian Cordasco - Oleg Broytman - Marc Labbé - Bruno Miguel Custódio - Florent Xicluna - Austin Mortonflake8-2.1.0/PKG-INFO0000644000175000001440000002131612233022416014725 0ustar icordascusers00000000000000Metadata-Version: 1.1 Name: flake8 Version: 2.1.0 Summary: the modular source code checker: pep8, pyflakes and co Home-page: http://bitbucket.org/tarek/flake8 Author: Ian Cordasco Author-email: graffatcolmingov@gmail.com License: MIT Description: ====== Flake8 ====== Flake8 is a wrapper around these tools: - PyFlakes - pep8 - Ned Batchelder's McCabe script Flake8 runs all the tools by launching the single ``flake8`` script. It displays the warnings in a per-file, merged output. It also adds a few features: - files that contain this line are skipped:: # flake8: noqa - lines that contain a ``# noqa`` comment at the end will not issue warnings. - a Git and a Mercurial hook. - a McCabe complexity checker. - extendable through ``flake8.extension`` entry points. QuickStart ========== :: pip install flake8 To run flake8 just invoke it against any directory or Python module:: $ flake8 coolproject coolproject/mod.py:97:1: F401 'shutil' imported but unused coolproject/mod.py:625:17: E225 missing whitespace around operato coolproject/mod.py:729:1: F811 redefinition of function 'readlines' from line 723 coolproject/mod.py:1028:1: F841 local variable 'errors' is assigned to but never used The outputs of PyFlakes *and* pep8 (and the optional plugins) are merged and returned. flake8 offers an extra option: --max-complexity, which will emit a warning if the McCabe complexity of a function is higher than the value. By default it's deactivated:: $ flake8 --max-complexity 12 coolproject coolproject/mod.py:97:1: F401 'shutil' imported but unused coolproject/mod.py:625:17: E225 missing whitespace around operator coolproject/mod.py:729:1: F811 redefinition of unused 'readlines' from line 723 coolproject/mod.py:939:1: C901 'Checker.check_all' is too complex (12) coolproject/mod.py:1028:1: F841 local variable 'errors' is assigned to but never used coolproject/mod.py:1204:1: C901 'selftest' is too complex (14) This feature is quite useful to detect over-complex code. According to McCabe, anything that goes beyond 10 is too complex. See https://en.wikipedia.org/wiki/Cyclomatic_complexity. Questions or Feedback ===================== If you have questions you'd like to ask the developers, or feedback you'd like to provide, feel free to use the mailing list: code-quality@python.org We would love to hear from you. Additionally, if you have a feature you'd like to suggest, the mailing list would be the best place for it. .. _links: Links ===== * `flake8 documentation `_ * `pep8 documentation `_ CHANGES ======= 2.1.0 - 2013-10-26 ------------------ - Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and mercurial hooks - Force git and mercurial hooks to repsect configuration in setup.cfg - Only check staged files if that is specified - Fix hook file permissions - Fix the git hook on python 3 - Ignore non-python files when running the git hook - Ignore .tox directories by default - Flake8 now reports the column number for PyFlakes messages 2.0.0 - 2013-02-23 ------------------ - Pyflakes errors are prefixed by an ``F`` instead of an ``E`` - McCabe complexity warnings are prefixed by a ``C`` instead of a ``W`` - Flake8 supports extensions through entry points - Due to the above support, we **require** setuptools - We publish the `documentation `_ - Fixes #13: pep8, pyflakes and mccabe become external dependencies - Split run.py into main.py, engine.py and hooks.py for better logic - Expose our parser for our users - New feature: Install git and hg hooks automagically - By relying on pyflakes (0.6.1), we also fixed #45 and #35 1.7.0 - 2012-12-21 ------------------ - Fixes part of #35: Exception for no WITHITEM being an attribute of Checker for Python 3.3 - Support stdin - Incorporate @phd's builtins pull request - Fix the git hook - Update pep8.py to the latest version 1.6.2 - 2012-11-25 ------------------ - fixed the NameError: global name 'message' is not defined (#46) 1.6.1 - 2012-11-24 ------------------ - fixed the mercurial hook, a change from a previous patch was not properly applied - fixed an assumption about warnings/error messages that caused an exception to be thrown when McCabe is used 1.6 - 2012-11-16 ---------------- - changed the signatures of the ``check_file`` function in flake8/run.py, ``skip_warning`` in flake8/util.py and the ``check``, ``checkPath`` functions in flake8/pyflakes.py. - fix ``--exclude`` and ``--ignore`` command flags (#14, #19) - fix the git hook that wasn't catching files not already added to the index (#29) - pre-emptively includes the addition to pep8 to ignore certain lines. Add ``# nopep8`` to the end of a line to ignore it. (#37) - ``check_file`` can now be used without any special prior setup (#21) - unpacking exceptions will no longer cause an exception (#20) - fixed crash on non-existent file (#38) 1.5 - 2012-10-13 ---------------- - fixed the stdin - make sure mccabe catches the syntax errors as warnings - pep8 upgrade - added max_line_length default value - added Flake8Command and entry points is setuptools is around - using the setuptools console wrapper when available 1.4 - 2012-07-12 ---------------- - git_hook: Only check staged changes for compliance - use pep8 1.2 1.3.1 - 2012-05-19 ------------------ - fixed support for Python 2.5 1.3 - 2012-03-12 ---------------- - fixed false W402 warning on exception blocks. 1.2 - 2012-02-12 ---------------- - added a git hook - now Python 3 compatible - mccabe and pyflakes have warning codes like pep8 now 1.1 - 2012-02-14 ---------------- - fixed the value returned by --version - allow the flake8: header to be more generic - fixed the "hg hook raises 'physical lines'" bug - allow three argument form of raise - now uses setuptools if available, for 'develop' command 1.0 - 2011-11-29 ---------------- - Deactivates by default the complexity checker - Introduces the complexity option in the HG hook and the command line. 0.9 - 2011-11-09 ---------------- - update pep8 version to 0.6.1 - mccabe check: gracefully handle compile failure 0.8 - 2011-02-27 ---------------- - fixed hg hook - discard unexisting files on hook check 0.7 - 2010-02-18 ---------------- - Fix pep8 initialization when run through Hg - Make pep8 short options work when run through the command line - Skip duplicates when controlling files via Hg 0.6 - 2010-02-15 ---------------- - Fix the McCabe metric on some loops Platform: UNKNOWN Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Quality Assurance flake8-2.1.0/LICENSE0000644000175000001440000000222412165553306014645 0ustar icordascusers00000000000000== Flake8 License (MIT) == Copyright (C) 2011-2013 Tarek Ziade Copyright (C) 2012-2013 Ian Cordasco Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. flake8-2.1.0/README.rst0000644000175000001440000000457112165553306015336 0ustar icordascusers00000000000000====== Flake8 ====== Flake8 is a wrapper around these tools: - PyFlakes - pep8 - Ned Batchelder's McCabe script Flake8 runs all the tools by launching the single ``flake8`` script. It displays the warnings in a per-file, merged output. It also adds a few features: - files that contain this line are skipped:: # flake8: noqa - lines that contain a ``# noqa`` comment at the end will not issue warnings. - a Git and a Mercurial hook. - a McCabe complexity checker. - extendable through ``flake8.extension`` entry points. QuickStart ========== :: pip install flake8 To run flake8 just invoke it against any directory or Python module:: $ flake8 coolproject coolproject/mod.py:97:1: F401 'shutil' imported but unused coolproject/mod.py:625:17: E225 missing whitespace around operato coolproject/mod.py:729:1: F811 redefinition of function 'readlines' from line 723 coolproject/mod.py:1028:1: F841 local variable 'errors' is assigned to but never used The outputs of PyFlakes *and* pep8 (and the optional plugins) are merged and returned. flake8 offers an extra option: --max-complexity, which will emit a warning if the McCabe complexity of a function is higher than the value. By default it's deactivated:: $ flake8 --max-complexity 12 coolproject coolproject/mod.py:97:1: F401 'shutil' imported but unused coolproject/mod.py:625:17: E225 missing whitespace around operator coolproject/mod.py:729:1: F811 redefinition of unused 'readlines' from line 723 coolproject/mod.py:939:1: C901 'Checker.check_all' is too complex (12) coolproject/mod.py:1028:1: F841 local variable 'errors' is assigned to but never used coolproject/mod.py:1204:1: C901 'selftest' is too complex (14) This feature is quite useful to detect over-complex code. According to McCabe, anything that goes beyond 10 is too complex. See https://en.wikipedia.org/wiki/Cyclomatic_complexity. Questions or Feedback ===================== If you have questions you'd like to ask the developers, or feedback you'd like to provide, feel free to use the mailing list: code-quality@python.org We would love to hear from you. Additionally, if you have a feature you'd like to suggest, the mailing list would be the best place for it. .. _links: Links ===== * `flake8 documentation `_ * `pep8 documentation `_ flake8-2.1.0/flake8.egg-info/0000755000175000001440000000000012233022416016471 5ustar icordascusers00000000000000flake8-2.1.0/flake8.egg-info/PKG-INFO0000644000175000001440000002131612233022416017571 0ustar icordascusers00000000000000Metadata-Version: 1.1 Name: flake8 Version: 2.1.0 Summary: the modular source code checker: pep8, pyflakes and co Home-page: http://bitbucket.org/tarek/flake8 Author: Ian Cordasco Author-email: graffatcolmingov@gmail.com License: MIT Description: ====== Flake8 ====== Flake8 is a wrapper around these tools: - PyFlakes - pep8 - Ned Batchelder's McCabe script Flake8 runs all the tools by launching the single ``flake8`` script. It displays the warnings in a per-file, merged output. It also adds a few features: - files that contain this line are skipped:: # flake8: noqa - lines that contain a ``# noqa`` comment at the end will not issue warnings. - a Git and a Mercurial hook. - a McCabe complexity checker. - extendable through ``flake8.extension`` entry points. QuickStart ========== :: pip install flake8 To run flake8 just invoke it against any directory or Python module:: $ flake8 coolproject coolproject/mod.py:97:1: F401 'shutil' imported but unused coolproject/mod.py:625:17: E225 missing whitespace around operato coolproject/mod.py:729:1: F811 redefinition of function 'readlines' from line 723 coolproject/mod.py:1028:1: F841 local variable 'errors' is assigned to but never used The outputs of PyFlakes *and* pep8 (and the optional plugins) are merged and returned. flake8 offers an extra option: --max-complexity, which will emit a warning if the McCabe complexity of a function is higher than the value. By default it's deactivated:: $ flake8 --max-complexity 12 coolproject coolproject/mod.py:97:1: F401 'shutil' imported but unused coolproject/mod.py:625:17: E225 missing whitespace around operator coolproject/mod.py:729:1: F811 redefinition of unused 'readlines' from line 723 coolproject/mod.py:939:1: C901 'Checker.check_all' is too complex (12) coolproject/mod.py:1028:1: F841 local variable 'errors' is assigned to but never used coolproject/mod.py:1204:1: C901 'selftest' is too complex (14) This feature is quite useful to detect over-complex code. According to McCabe, anything that goes beyond 10 is too complex. See https://en.wikipedia.org/wiki/Cyclomatic_complexity. Questions or Feedback ===================== If you have questions you'd like to ask the developers, or feedback you'd like to provide, feel free to use the mailing list: code-quality@python.org We would love to hear from you. Additionally, if you have a feature you'd like to suggest, the mailing list would be the best place for it. .. _links: Links ===== * `flake8 documentation `_ * `pep8 documentation `_ CHANGES ======= 2.1.0 - 2013-10-26 ------------------ - Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and mercurial hooks - Force git and mercurial hooks to repsect configuration in setup.cfg - Only check staged files if that is specified - Fix hook file permissions - Fix the git hook on python 3 - Ignore non-python files when running the git hook - Ignore .tox directories by default - Flake8 now reports the column number for PyFlakes messages 2.0.0 - 2013-02-23 ------------------ - Pyflakes errors are prefixed by an ``F`` instead of an ``E`` - McCabe complexity warnings are prefixed by a ``C`` instead of a ``W`` - Flake8 supports extensions through entry points - Due to the above support, we **require** setuptools - We publish the `documentation `_ - Fixes #13: pep8, pyflakes and mccabe become external dependencies - Split run.py into main.py, engine.py and hooks.py for better logic - Expose our parser for our users - New feature: Install git and hg hooks automagically - By relying on pyflakes (0.6.1), we also fixed #45 and #35 1.7.0 - 2012-12-21 ------------------ - Fixes part of #35: Exception for no WITHITEM being an attribute of Checker for Python 3.3 - Support stdin - Incorporate @phd's builtins pull request - Fix the git hook - Update pep8.py to the latest version 1.6.2 - 2012-11-25 ------------------ - fixed the NameError: global name 'message' is not defined (#46) 1.6.1 - 2012-11-24 ------------------ - fixed the mercurial hook, a change from a previous patch was not properly applied - fixed an assumption about warnings/error messages that caused an exception to be thrown when McCabe is used 1.6 - 2012-11-16 ---------------- - changed the signatures of the ``check_file`` function in flake8/run.py, ``skip_warning`` in flake8/util.py and the ``check``, ``checkPath`` functions in flake8/pyflakes.py. - fix ``--exclude`` and ``--ignore`` command flags (#14, #19) - fix the git hook that wasn't catching files not already added to the index (#29) - pre-emptively includes the addition to pep8 to ignore certain lines. Add ``# nopep8`` to the end of a line to ignore it. (#37) - ``check_file`` can now be used without any special prior setup (#21) - unpacking exceptions will no longer cause an exception (#20) - fixed crash on non-existent file (#38) 1.5 - 2012-10-13 ---------------- - fixed the stdin - make sure mccabe catches the syntax errors as warnings - pep8 upgrade - added max_line_length default value - added Flake8Command and entry points is setuptools is around - using the setuptools console wrapper when available 1.4 - 2012-07-12 ---------------- - git_hook: Only check staged changes for compliance - use pep8 1.2 1.3.1 - 2012-05-19 ------------------ - fixed support for Python 2.5 1.3 - 2012-03-12 ---------------- - fixed false W402 warning on exception blocks. 1.2 - 2012-02-12 ---------------- - added a git hook - now Python 3 compatible - mccabe and pyflakes have warning codes like pep8 now 1.1 - 2012-02-14 ---------------- - fixed the value returned by --version - allow the flake8: header to be more generic - fixed the "hg hook raises 'physical lines'" bug - allow three argument form of raise - now uses setuptools if available, for 'develop' command 1.0 - 2011-11-29 ---------------- - Deactivates by default the complexity checker - Introduces the complexity option in the HG hook and the command line. 0.9 - 2011-11-09 ---------------- - update pep8 version to 0.6.1 - mccabe check: gracefully handle compile failure 0.8 - 2011-02-27 ---------------- - fixed hg hook - discard unexisting files on hook check 0.7 - 2010-02-18 ---------------- - Fix pep8 initialization when run through Hg - Make pep8 short options work when run through the command line - Skip duplicates when controlling files via Hg 0.6 - 2010-02-15 ---------------- - Fix the McCabe metric on some loops Platform: UNKNOWN Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Quality Assurance flake8-2.1.0/flake8.egg-info/dependency_links.txt0000644000175000001440000000000112233022416022537 0ustar icordascusers00000000000000 flake8-2.1.0/flake8.egg-info/requires.txt0000644000175000001440000000005712233022416021073 0ustar icordascusers00000000000000pyflakes >= 0.7.3 pep8 >= 1.4.6 mccabe >= 0.2.1flake8-2.1.0/flake8.egg-info/entry_points.txt0000644000175000001440000000023512233022416021767 0ustar icordascusers00000000000000[flake8.extension] F = flake8._pyflakes:FlakesChecker [console_scripts] flake8 = flake8.main:main [distutils.commands] flake8 = flake8.main:Flake8Command flake8-2.1.0/flake8.egg-info/SOURCES.txt0000644000175000001440000000145112233022416020356 0ustar icordascusers00000000000000CHANGES.rst CONTRIBUTORS.txt LICENSE MANIFEST.in README.rst setup.py flake8/__init__.py flake8/__init__.pyc flake8/_pyflakes.py flake8/_pyflakes.pyc flake8/engine.py flake8/engine.pyc flake8/hooks.py flake8/hooks.py.orig flake8/hooks.pyc flake8/main.py flake8/main.pyc flake8/run.py flake8/util.py flake8/util.pyc flake8.egg-info/PKG-INFO flake8.egg-info/SOURCES.txt flake8.egg-info/dependency_links.txt flake8.egg-info/entry_points.txt flake8.egg-info/requires.txt flake8.egg-info/top_level.txt flake8/__pycache__/__init__.cpython-32.pyc flake8/__pycache__/_pyflakes.cpython-32.pyc flake8/__pycache__/engine.cpython-32.pyc flake8/__pycache__/main.cpython-32.pyc flake8/__pycache__/util.cpython-32.pyc flake8/tests/__init__.py flake8/tests/__init__.pyc flake8/tests/test_engine.py flake8/tests/test_engine.pycflake8-2.1.0/flake8.egg-info/top_level.txt0000644000175000001440000000000712233022416021220 0ustar icordascusers00000000000000flake8 flake8-2.1.0/CHANGES.rst0000644000175000001440000000757412233022263015444 0ustar icordascusers00000000000000CHANGES ======= 2.1.0 - 2013-10-26 ------------------ - Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and mercurial hooks - Force git and mercurial hooks to repsect configuration in setup.cfg - Only check staged files if that is specified - Fix hook file permissions - Fix the git hook on python 3 - Ignore non-python files when running the git hook - Ignore .tox directories by default - Flake8 now reports the column number for PyFlakes messages 2.0.0 - 2013-02-23 ------------------ - Pyflakes errors are prefixed by an ``F`` instead of an ``E`` - McCabe complexity warnings are prefixed by a ``C`` instead of a ``W`` - Flake8 supports extensions through entry points - Due to the above support, we **require** setuptools - We publish the `documentation `_ - Fixes #13: pep8, pyflakes and mccabe become external dependencies - Split run.py into main.py, engine.py and hooks.py for better logic - Expose our parser for our users - New feature: Install git and hg hooks automagically - By relying on pyflakes (0.6.1), we also fixed #45 and #35 1.7.0 - 2012-12-21 ------------------ - Fixes part of #35: Exception for no WITHITEM being an attribute of Checker for Python 3.3 - Support stdin - Incorporate @phd's builtins pull request - Fix the git hook - Update pep8.py to the latest version 1.6.2 - 2012-11-25 ------------------ - fixed the NameError: global name 'message' is not defined (#46) 1.6.1 - 2012-11-24 ------------------ - fixed the mercurial hook, a change from a previous patch was not properly applied - fixed an assumption about warnings/error messages that caused an exception to be thrown when McCabe is used 1.6 - 2012-11-16 ---------------- - changed the signatures of the ``check_file`` function in flake8/run.py, ``skip_warning`` in flake8/util.py and the ``check``, ``checkPath`` functions in flake8/pyflakes.py. - fix ``--exclude`` and ``--ignore`` command flags (#14, #19) - fix the git hook that wasn't catching files not already added to the index (#29) - pre-emptively includes the addition to pep8 to ignore certain lines. Add ``# nopep8`` to the end of a line to ignore it. (#37) - ``check_file`` can now be used without any special prior setup (#21) - unpacking exceptions will no longer cause an exception (#20) - fixed crash on non-existent file (#38) 1.5 - 2012-10-13 ---------------- - fixed the stdin - make sure mccabe catches the syntax errors as warnings - pep8 upgrade - added max_line_length default value - added Flake8Command and entry points is setuptools is around - using the setuptools console wrapper when available 1.4 - 2012-07-12 ---------------- - git_hook: Only check staged changes for compliance - use pep8 1.2 1.3.1 - 2012-05-19 ------------------ - fixed support for Python 2.5 1.3 - 2012-03-12 ---------------- - fixed false W402 warning on exception blocks. 1.2 - 2012-02-12 ---------------- - added a git hook - now Python 3 compatible - mccabe and pyflakes have warning codes like pep8 now 1.1 - 2012-02-14 ---------------- - fixed the value returned by --version - allow the flake8: header to be more generic - fixed the "hg hook raises 'physical lines'" bug - allow three argument form of raise - now uses setuptools if available, for 'develop' command 1.0 - 2011-11-29 ---------------- - Deactivates by default the complexity checker - Introduces the complexity option in the HG hook and the command line. 0.9 - 2011-11-09 ---------------- - update pep8 version to 0.6.1 - mccabe check: gracefully handle compile failure 0.8 - 2011-02-27 ---------------- - fixed hg hook - discard unexisting files on hook check 0.7 - 2010-02-18 ---------------- - Fix pep8 initialization when run through Hg - Make pep8 short options work when run through the command line - Skip duplicates when controlling files via Hg 0.6 - 2010-02-15 ---------------- - Fix the McCabe metric on some loops flake8-2.1.0/flake8/0000755000175000001440000000000012233022416014777 5ustar icordascusers00000000000000flake8-2.1.0/flake8/util.pyc0000644000175000001440000000363612166066416016516 0ustar icordascusers00000000000000 oQc@syddlZejZWn\ek rwddlZdejjkrkd ej_edej_ndZnXde fdYZ dZ dZ dS( iNtdecorator_listcCs|jS(N(t decorators(ts((s./flake8/util.pyt sccs|js dSxz|jD]o}t||d}t|tjrI|Vqt|trx+|D] }t|tjr_|Vq_q_WqqWdS(s Yield all direct child nodes of *node*, that is, all fields that are nodes and all items of fields that are lists of nodes. N(t_fieldstgetattrtNonet isinstancetasttASTtlist(tnodetnametfieldtitem((s./flake8/util.pytiter_child_nodess  t OrderedSetcBseZdZdZdZRS(sList without duplicates.cCs ||kr|j|ndS(N(tappend(tselftvalue((s./flake8/util.pytadd#s ((t__name__t __module__t__doc__t __slots__R(((s./flake8/util.pyRsc Cst|}|jd kS( s,Guess if the value could be an on/off togglet1t0tFtTtTRUEtFALSEtONtOFF(RRRRRRRR (tstrtupper(tval((s./flake8/util.pytis_flag(s cCst|jdkS(sReturn true if flag is onRRRR(RRsTRUEsON(R!R"(R#((s./flake8/util.pytflag_on.s(( RRt ImportErrort_asttClassDefRRtpropertyt FunctionDefR RR$R%(((s./flake8/util.pyts       flake8-2.1.0/flake8/tests/0000755000175000001440000000000012233022416016141 5ustar icordascusers00000000000000flake8-2.1.0/flake8/tests/__init__.py0000644000175000001440000000000212161467632020257 0ustar icordascusers00000000000000# flake8-2.1.0/flake8/tests/__init__.pyc0000644000175000001440000000016112166032716020424 0ustar icordascusers00000000000000 oQc@sdS(N((((s./flake8/tests/__init__.pytsflake8-2.1.0/flake8/tests/test_engine.py0000644000175000001440000000564012166037044021034 0ustar icordascusers00000000000000from flake8 import engine, util, __version__ import pep8 import unittest import mock class TestEngine(unittest.TestCase): def setUp(self): self.patches = {} def tearDown(self): assert len(self.patches.items()) == 0 def start_patch(self, patch): self.patches[patch] = mock.patch(patch) return self.patches[patch].start() def stop_patches(self): patches = self.patches.copy() for k, v in patches.items(): v.stop() del(self.patches[k]) def test_get_style_guide(self): with mock.patch('flake8.engine._register_extensions') as reg_ext: reg_ext.return_value = ([], [], []) g = engine.get_style_guide() self.assertTrue(isinstance(g, engine.StyleGuide)) reg_ext.assert_called_once_with() def test_get_style_guide_kwargs(self): m = mock.Mock() with mock.patch('flake8.engine.StyleGuide') as StyleGuide: with mock.patch('flake8.engine.get_parser') as get_parser: get_parser.return_value = (m, []) engine.get_style_guide(foo='bar') get_parser.assert_called_once_with() StyleGuide.assert_called_once_with(**{'parser': m, 'foo': 'bar'}) def test_register_extensions(self): with mock.patch('pep8.register_check') as register_check: registered_extensions = engine._register_extensions() self.assertTrue(isinstance(registered_extensions[0], util.OrderedSet)) self.assertTrue(len(registered_extensions[0]) > 0) for i in registered_extensions[1:]: self.assertTrue(isinstance(i, list)) register_check.assert_called() def test_get_parser(self): # setup re = self.start_patch('flake8.engine._register_extensions') gpv = self.start_patch('flake8.engine.get_python_version') pgp = self.start_patch('pep8.get_parser') m = mock.Mock() re.return_value = ([('pyflakes', '0.7'), ('mccabe', '0.2')], [], []) gpv.return_value = 'Python Version' pgp.return_value = m # actual call we're testing parser, hooks = engine.get_parser() # assertions re.assert_called() gpv.assert_called() pgp.assert_called_once_with( 'flake8', '%s (pyflakes: 0.7, mccabe: 0.2) Python Version' % __version__ ) m.remove_option.assert_called() m.add_option.assert_called() self.assertEqual(parser, m) self.assertEqual(hooks, []) # clean-up self.stop_patches() def test_get_python_version(self): self.assertTrue('on' in engine.get_python_version()) # Silly test but it will provide 100% test coverage # Also we can never be sure (without reconstructing the string # ourselves) what system we may be testing on. if __name__ == '__main__': unittest.main() flake8-2.1.0/flake8/tests/test_engine.pyc0000644000175000001440000000717412166066402021203 0ustar icordascusers00000000000000 $>Qc@svddlmZmZmZddlZddlZddlZdejfdYZe dkrrej ndS(i(tenginetutilt __version__Nt TestEnginecBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCs i|_dS(N(tpatches(tself((s./flake8/tests/test_engine.pytsetUpscCs%t|jjdks!tdS(Ni(tlenRtitemstAssertionError(R((s./flake8/tests/test_engine.pyttearDown scCs'tj||j|<|j|jS(N(tmocktpatchRtstart(RR ((s./flake8/tests/test_engine.pyt start_patchscCsD|jj}x.|jD] \}}|j|j|=qWdS(N(RtcopyRtstop(RRtktv((s./flake8/tests/test_engine.pyt stop_patchess cCs]tjdH}gggf|_tj}|jt|tj|jWdQXdS(Ns"flake8.engine._register_extensions( R R t return_valueRtget_style_guidet assertTruet isinstancet StyleGuidetassert_called_once_with(Rtreg_exttg((s./flake8/tests/test_engine.pyttest_get_style_guides  c Cstj}tjdc}tjd0}|gf|_tjdd|jWdQX|ji|d6dd6WdQXdS(Nsflake8.engine.StyleGuidesflake8.engine.get_parsertfootbartparser(R tMockR RRRR(RtmRt get_parser((s./flake8/tests/test_engine.pyttest_get_style_guide_kwargss c Cstjd}tj}|jt|dtj|jt|ddkx(|dD]}|jt|t qcW|j WdQXdS(Nspep8.register_checkii( R R Rt_register_extensionsRRRt OrderedSetRtlistt assert_called(Rtregister_checktregistered_extensionsti((s./flake8/tests/test_engine.pyttest_register_extensions(s cCs|jd}|jd}|jd}tj}d d gggf|_d|_||_tj\}}|j|j|jd d t|j j|j j|j |||j |g|j dS( Ns"flake8.engine._register_extensionss flake8.engine.get_python_versionspep8.get_parsertpyflakess0.7tmccabes0.2sPython Versiontflake8s.%s (pyflakes: 0.7, mccabe: 0.2) Python Version(R,s0.7(R-s0.2( RR R RRR"R'RRt remove_optiont add_optiont assertEqualR(RtretgpvtpgpR!Rthooks((s./flake8/tests/test_engine.pyttest_get_parser1s$        cCs|jdtjkdS(Nton(RRtget_python_version(R((s./flake8/tests/test_engine.pyttest_get_python_versionJs( t__name__t __module__RR RRRR#R+R6R9(((s./flake8/tests/test_engine.pyRs      t__main__( R.RRRtpep8tunittestR tTestCaseRR:tmain(((s./flake8/tests/test_engine.pyts    I flake8-2.1.0/flake8/hooks.py.orig0000644000175000001440000001226512161467632017456 0ustar icordascusers00000000000000# -*- coding: utf-8 -*- from __future__ import with_statement import os import sys from subprocess import Popen, PIPE try: from mercurial import demandimport demandimport.disable() except ImportError: pass try: from configparser import ConfigParser except ImportError: # Python 2 from ConfigParser import ConfigParser from flake8.engine import get_parser, get_style_guide from flake8.main import DEFAULT_CONFIG def git_hook(complexity=-1, strict=False, ignore=None, lazy=False): """This is the function used by the git hook. :param int complexity: (optional), any value > 0 enables complexity checking with mccabe :param bool strict: (optional), if True, this returns the total number of errors which will cause the hook to fail :param str ignore: (optional), a comma-separated list of errors and warnings to ignore :param bool lazy: (optional), allows for the instances where you don't add the files to the index before running a commit, e.g., git commit -a :returns: total number of errors if strict is True, otherwise 0 """ gitcmd = "git diff-index --cached --name-only HEAD" if lazy: # Catch all files, including those not added to the index gitcmd = gitcmd.replace('--cached ', '') if hasattr(ignore, 'split'): ignore = ignore.split(',') # Returns the exit code, list of files modified, list of error messages _, files_modified, _ = run(gitcmd) # Run the checks flake8_style = get_style_guide( config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity) report = flake8_style.check_files([f for f in files_modified if f.endswith('.py')]) if strict: return report.total_errors return 0 def hg_hook(ui, repo, **kwargs): """This is the function executed directly by Mercurial as part of the hook. This is never called directly by the user, so the parameters are undocumented. If you would like to learn more about them, please feel free to read the official Mercurial documentation. """ complexity = ui.config('flake8', 'complexity', default=-1) strict = ui.configbool('flake8', 'strict', default=True) config = ui.config('flake8', 'config', default=True) if config is True: config = DEFAULT_CONFIG paths = _get_files(repo, **kwargs) flake8_style = get_style_guide( config_file=config, max_complexity=complexity) report = flake8_style.check_files(paths) if strict: return report.total_errors return 0 def run(command): p = Popen(command.split(), stdout=PIPE, stderr=PIPE) (stdout, stderr) = p.communicate() return (p.returncode, [line.strip() for line in stdout.splitlines()], [line.strip() for line in stderr.splitlines()]) def _get_files(repo, **kwargs): seen = set() for rev in range(repo[kwargs['node']], len(repo)): for file_ in repo[rev].files(): file_ = os.path.join(repo.root, file_) if file_ in seen or not os.path.exists(file_): continue seen.add(file_) if file_.endswith('.py'): yield file_ def find_vcs(): if os.path.isdir('.git'): if not os.path.isdir('.git/hooks'): os.mkdir('.git/hooks') return '.git/hooks/pre-commit' elif os.path.isdir('.hg'): return '.hg/hgrc' return '' git_hook_file = """#!/usr/bin/env python import sys import os from flake8.hooks import git_hook COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10) STRICT = os.getenv('FLAKE8_STRICT', False) if __name__ == '__main__': sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT)) """ def _install_hg_hook(path): if not os.path.isfile(path): # Make the file so we can avoid IOError's open(path, 'w+').close() c = ConfigParser() c.readfp(open(path, 'r')) if not c.has_section('hooks'): c.add_section('hooks') if not c.has_option('hooks', 'commit'): c.set('hooks', 'commit', 'python:flake8.hooks.hg_hook') if not c.has_option('hooks', 'qrefresh'): c.set('hooks', 'qrefresh', 'python:flake8.hooks.hg_hook') if not c.has_section('flake8'): c.add_section('flake8') if not c.has_option('flake8', 'complexity'): c.set('flake8', 'complexity', str(os.getenv('FLAKE8_COMPLEXITY', 10))) if not c.has_option('flake8', 'strict'): c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False)) c.write(open(path, 'w+')) def install_hook(): vcs = find_vcs() if not vcs: p = get_parser() sys.stderr.write('Error: could not find either a git or mercurial ' 'directory. Please re-run this in a proper ' 'repository.') p.print_help() sys.exit(1) status = 0 if 'git' in vcs: with open(vcs, 'w+') as fd: fd.write(git_hook_file) # 0b111100100 == rwxr--r-- # Python 2.5 doesn't support 0b syntax so note that the above binary # value is equivalent to 484 in decimal os.chmod(vcs, 484) elif 'hg' in vcs: _install_hg_hook(vcs) else: status = 1 sys.exit(status) flake8-2.1.0/flake8/util.py0000644000175000001440000000254412161467632016350 0ustar icordascusers00000000000000# -*- coding: utf-8 -*- try: import ast iter_child_nodes = ast.iter_child_nodes except ImportError: # Python 2.5 import _ast as ast if 'decorator_list' not in ast.ClassDef._fields: # Patch the missing attribute 'decorator_list' ast.ClassDef.decorator_list = () ast.FunctionDef.decorator_list = property(lambda s: s.decorators) def iter_child_nodes(node): """ Yield all direct child nodes of *node*, that is, all fields that are nodes and all items of fields that are lists of nodes. """ if not node._fields: return for name in node._fields: field = getattr(node, name, None) if isinstance(field, ast.AST): yield field elif isinstance(field, list): for item in field: if isinstance(item, ast.AST): yield item class OrderedSet(list): """List without duplicates.""" __slots__ = () def add(self, value): if value not in self: self.append(value) def is_flag(val): """Guess if the value could be an on/off toggle""" val = str(val) return val.upper() in ('1', '0', 'F', 'T', 'TRUE', 'FALSE', 'ON', 'OFF') def flag_on(val): """Return true if flag is on""" return str(val).upper() in ('1', 'T', 'TRUE', 'ON') flake8-2.1.0/flake8/hooks.py0000644000175000001440000002010512233011206016465 0ustar icordascusers00000000000000# -*- coding: utf-8 -*- from __future__ import with_statement import os import sys import stat from subprocess import Popen, PIPE import shutil from tempfile import mkdtemp try: # The 'demandimport' breaks pyflakes and flake8._pyflakes from mercurial import demandimport demandimport.disable() except ImportError: pass try: from configparser import ConfigParser except ImportError: # Python 2 from ConfigParser import ConfigParser from flake8.engine import get_parser, get_style_guide from flake8.main import DEFAULT_CONFIG def git_hook(complexity=-1, strict=False, ignore=None, lazy=False): """This is the function used by the git hook. :param int complexity: (optional), any value > 0 enables complexity checking with mccabe :param bool strict: (optional), if True, this returns the total number of errors which will cause the hook to fail :param str ignore: (optional), a comma-separated list of errors and warnings to ignore :param bool lazy: (optional), allows for the instances where you don't add the files to the index before running a commit, e.g., git commit -a :returns: total number of errors if strict is True, otherwise 0 """ gitcmd = "git diff-index --cached --name-only --diff-filter=ACMRTUXB HEAD" if lazy: # Catch all files, including those not added to the index gitcmd = gitcmd.replace('--cached ', '') if hasattr(ignore, 'split'): ignore = ignore.split(',') # Returns the exit code, list of files modified, list of error messages _, files_modified, _ = run(gitcmd) # We only want to pass ignore and max_complexity if they differ from the # defaults so that we don't override a local configuration file options = {} if ignore: options['ignore'] = ignore if complexity > -1: options['max_complexity'] = complexity files_modified = [f for f in files_modified if f.endswith('.py')] flake8_style = get_style_guide( parse_argv=True, config_file=DEFAULT_CONFIG, **options ) # Copy staged versions to temporary directory tmpdir = mkdtemp() files_to_check = [] try: for file_ in files_modified: # get the staged version of the file gitcmd_getstaged = "git show :%s" % file_ _, out, _ = run(gitcmd_getstaged, raw_output=True, decode=False) # write the staged version to temp dir with its full path to # avoid overwriting files with the same name dirname, filename = os.path.split(os.path.abspath(file_)) prefix = os.path.commonprefix([dirname, tmpdir]) dirname = os.path.relpath(dirname, start=prefix) dirname = os.path.join(tmpdir, dirname) if not os.path.isdir(dirname): os.makedirs(dirname) filename = os.path.join(dirname, filename) # write staged version of file to temporary directory with open(filename, "wb") as fh: fh.write(out) files_to_check.append(filename) # Run the checks report = flake8_style.check_files(files_to_check) # remove temporary directory finally: shutil.rmtree(tmpdir, ignore_errors=True) if strict: return report.total_errors return 0 def hg_hook(ui, repo, **kwargs): """This is the function executed directly by Mercurial as part of the hook. This is never called directly by the user, so the parameters are undocumented. If you would like to learn more about them, please feel free to read the official Mercurial documentation. """ complexity = ui.config('flake8', 'complexity', default=-1) strict = ui.configbool('flake8', 'strict', default=True) ignore = ui.config('flake8', 'ignore', default=None) config = ui.config('flake8', 'config', default=True) if config is True: config = DEFAULT_CONFIG paths = _get_files(repo, **kwargs) # We only want to pass ignore and max_complexity if they differ from the # defaults so that we don't override a local configuration file options = {} if ignore: options['ignore'] = ignore if complexity > -1: options['max_complexity'] = complexity flake8_style = get_style_guide(parse_argv=True, config_file=config, **options) report = flake8_style.check_files(paths) if strict: return report.total_errors return 0 def run(command, raw_output=False, decode=True): p = Popen(command.split(), stdout=PIPE, stderr=PIPE) (stdout, stderr) = p.communicate() # On python 3, subprocess.Popen returns bytes objects which expect # endswith to be given a bytes object or a tuple of bytes but not native # string objects. This is simply less mysterious than using b'.py' in the # endswith method. That should work but might still fail horribly. if hasattr(stdout, 'decode'): if decode: stdout = stdout.decode() if hasattr(stderr, 'decode'): if decode: stderr = stderr.decode() if not raw_output: stdout = [line.strip() for line in stdout.splitlines()] stderr = [line.strip() for line in stderr.splitlines()] return (p.returncode, stdout, stderr) def _get_files(repo, **kwargs): seen = set() for rev in range(repo[kwargs['node']], len(repo)): for file_ in repo[rev].files(): file_ = os.path.join(repo.root, file_) if file_ in seen or not os.path.exists(file_): continue seen.add(file_) if file_.endswith('.py'): yield file_ def find_vcs(): _, git_dir, _ = run('git rev-parse --git-dir') if git_dir and os.path.isdir(git_dir[0]): if not os.path.isdir(os.path.join(git_dir[0], 'hooks')): os.mkdir(os.path.join(git_dir[0], 'hooks')) return os.path.join(git_dir[0], 'hooks', 'pre-commit') _, hg_dir, _ = run('hg root') if hg_dir and os.path.isdir(hg_dir[0]): return os.path.join(hg_dir[0], '.hg', 'hgrc') return '' git_hook_file = """#!/usr/bin/env python import sys import os from flake8.hooks import git_hook COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10) STRICT = os.getenv('FLAKE8_STRICT', False) IGNORE = os.getenv('FLAKE8_IGNORE') LAZY = os.getenv('FLAKE8_LAZY', False) if __name__ == '__main__': sys.exit(git_hook( complexity=COMPLEXITY, strict=STRICT, ignore=IGNORE, lazy=LAZY, )) """ def _install_hg_hook(path): if not os.path.isfile(path): # Make the file so we can avoid IOError's open(path, 'w+').close() c = ConfigParser() c.readfp(open(path, 'r')) if not c.has_section('hooks'): c.add_section('hooks') if not c.has_option('hooks', 'commit'): c.set('hooks', 'commit', 'python:flake8.hooks.hg_hook') if not c.has_option('hooks', 'qrefresh'): c.set('hooks', 'qrefresh', 'python:flake8.hooks.hg_hook') if not c.has_section('flake8'): c.add_section('flake8') if not c.has_option('flake8', 'complexity'): c.set('flake8', 'complexity', str(os.getenv('FLAKE8_COMPLEXITY', 10))) if not c.has_option('flake8', 'strict'): c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False)) if not c.has_option('flake8', 'ignore'): c.set('flake8', 'ignore', os.getenv('FLAKE8_IGNORE')) if not c.has_option('flake8', 'lazy'): c.set('flake8', 'lazy', os.getenv('FLAKE8_LAZY', False)) c.write(open(path, 'w+')) def install_hook(): vcs = find_vcs() if not vcs: p = get_parser()[0] sys.stderr.write('Error: could not find either a git or mercurial ' 'directory. Please re-run this in a proper ' 'repository.') p.print_help() sys.exit(1) status = 0 if 'git' in vcs: with open(vcs, 'w+') as fd: fd.write(git_hook_file) # rwxr--r-- os.chmod(vcs, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH) elif 'hg' in vcs: _install_hg_hook(vcs) else: status = 1 sys.exit(status) flake8-2.1.0/flake8/main.py0000644000175000001440000001041212224011525016272 0ustar icordascusers00000000000000# -*- coding: utf-8 -*- import os import sys import setuptools from flake8.engine import get_parser, get_style_guide from flake8.util import is_flag, flag_on if sys.platform.startswith('win'): DEFAULT_CONFIG = os.path.expanduser(r'~\.flake8') else: DEFAULT_CONFIG = os.path.join( os.getenv('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'), 'flake8' ) EXTRA_IGNORE = ['.tox'] def main(): """Parse options and run checks on Python source.""" # Prepare flake8_style = get_style_guide(parse_argv=True, config_file=DEFAULT_CONFIG) options = flake8_style.options if options.install_hook: from flake8.hooks import install_hook install_hook() # Run the checkers report = flake8_style.check_files() exit_code = print_report(report, flake8_style) raise SystemExit(exit_code > 0) def print_report(report, flake8_style): # Print the final report options = flake8_style.options if options.statistics: report.print_statistics() if options.benchmark: report.print_benchmark() if report.total_errors: if options.count: sys.stderr.write(str(report.total_errors) + '\n') if not options.exit_zero: return 1 return 0 def check_file(path, ignore=(), complexity=-1): """Checks a file using pep8 and pyflakes by default and mccabe optionally. :param str path: path to the file to be checked :param tuple ignore: (optional), error and warning codes to be ignored :param int complexity: (optional), enables the mccabe check for values > 0 """ ignore = set(ignore).union(EXTRA_IGNORE) flake8_style = get_style_guide( config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity) return flake8_style.input_file(path) def check_code(code, ignore=(), complexity=-1): """Checks code using pep8 and pyflakes by default and mccabe optionally. :param str code: code to be checked :param tuple ignore: (optional), error and warning codes to be ignored :param int complexity: (optional), enables the mccabe check for values > 0 """ ignore = set(ignore).union(EXTRA_IGNORE) flake8_style = get_style_guide( config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity) return flake8_style.input_file(None, lines=code.splitlines(True)) class Flake8Command(setuptools.Command): """The :class:`Flake8Command` class is used by setuptools to perform checks on registered modules. """ description = "Run flake8 on modules registered in setuptools" user_options = [] def initialize_options(self): self.option_to_cmds = {} parser = get_parser()[0] for opt in parser.option_list: cmd_name = opt._long_opts[0][2:] option_name = cmd_name.replace('-', '_') self.option_to_cmds[option_name] = cmd_name setattr(self, option_name, None) def finalize_options(self): self.options_dict = {} for (option_name, cmd_name) in self.option_to_cmds.items(): if option_name in ['help', 'verbose']: continue value = getattr(self, option_name) if value is None: continue if is_flag(value): value = flag_on(value) self.options_dict[option_name] = value def distribution_files(self): if self.distribution.packages: package_dirs = self.distribution.package_dir or {} for package in self.distribution.packages: pkg_dir = package if package in package_dirs: pkg_dir = package_dirs[package] elif '' in package_dirs: pkg_dir = package_dirs[''] + os.path.sep + pkg_dir yield pkg_dir.replace('.', os.path.sep) if self.distribution.py_modules: for filename in self.distribution.py_modules: yield "%s.py" % filename def run(self): flake8_style = get_style_guide(config_file=DEFAULT_CONFIG, **self.options_dict) paths = self.distribution_files() report = flake8_style.check_files(paths) exit_code = print_report(report, flake8_style) raise SystemExit(exit_code > 0) flake8-2.1.0/flake8/__init__.py0000644000175000001440000000002612233022363017107 0ustar icordascusers00000000000000__version__ = '2.1.0' flake8-2.1.0/flake8/__init__.pyc0000644000175000001440000000021112166032716017256 0ustar icordascusers00000000000000 oQc@s dZdS(s2.0N(t __version__(((s./flake8/__init__.pytsflake8-2.1.0/flake8/__pycache__/0000755000175000001440000000000012233022416017207 5ustar icordascusers00000000000000flake8-2.1.0/flake8/__pycache__/_pyflakes.cpython-32.pyc0000644000175000001440000000561412161467632023631 0ustar icordascusers00000000000000l (Qc@sEddlZddlZdZeGddejjZdS(iNcCs~tddD}xattjjD]J\}}|djr,|jr,d|j|d|jf|_q,q,WdS(u%Add error codes to Pyflakes messages.cSs)g|]}|jdddqS(Nii(usplit(u.0uline((u1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyu s uF401 UnusedImportuF402 ImportShadowedByLoopVaruF403 ImportStarUseduF404 LateFutureImportuF810 RedefineduF811 RedefinedWhileUnuseduF812 RedefinedInListCompuF821 UndefinedNameuF822 UndefinedExportuF823 UndefinedLocaluF831 DuplicateArgumentuF841 UnusedVariableiu%s %suF999N( uF401 UnusedImportuF402 ImportShadowedByLoopVaruF403 ImportStarUseduF404 LateFutureImportuF810 RedefineduF811 RedefinedWhileUnuseduF812 RedefinedInListCompuF821 UndefinedNameuF822 UndefinedExportuF823 UndefinedLocaluF831 DuplicateArgumentuF841 UnusedVariable( udictuvarsupyflakesumessagesuitemsuisupperumessageugetu flake8_msg(ucodesunameuobj((u1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyupatch_pyflakess   "cBsJ|EeZdZdZejZedZedZ dZ dS(u=Subclass the Pyflakes checker to conform with the flake8 API.upyflakescCs'|jddd|jjddS(Nu --builtinsuhelpu&define more built-ins, comma separatedubuiltins(u add_optionuconfig_optionsuappend(uclsuparser((u1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyu add_options"s cCs1|jr-|jj|jjd|_ndS(Nu,(ubuiltinsubuiltInsuunionusplit(uclsuoptions((u1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyu parse_options(s ccs9x2|jD]'}|jd|j|j|jfVq WdS(Ni(umessagesulinenou flake8_msgu message_argsu __class__(uselfum((u1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyurun-sN( u__name__u __module__u__doc__unameupyflakesu __version__uversionu classmethodu add_optionsu parse_optionsurun(u __locals__((u1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyu FlakesCheckers  u FlakesChecker(upyflakesupyflakes.checkerupatch_pyflakesucheckeruCheckeru FlakesChecker(((u1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyus   flake8-2.1.0/flake8/__pycache__/engine.cpython-32.pyc0000644000175000001440000001064112161467632023115 0ustar icordascusers00000000000000l A*Qc@sddlZddlZddlZddlmZddlmZejdejj Z dZ dZ Gddej Z d Zd ZdS( iN(u __version__(u OrderedSetuflake8[:=]\s*noqac Cst}|jdtjfg}g}yddlm}Wntk rSYnXx|dD]}|j}tj|d|j g|j|j |j ft |dr|j |j nt |dra|j |jqaqaW|||fS(uRegister all the extensions.upep8i(uiter_entry_pointsuflake8.extensionucodesu add_optionsu parse_options(u OrderedSetuaddupep8u __version__u pkg_resourcesuiter_entry_pointsu ImportErroruloaduregister_checkunameuversionuhasattruappendu add_optionsu parse_options(u extensionsu parser_hooksu options_hooksuiter_entry_pointsuentryuchecker((u./home/icordasc/sandbox/flake8/flake8/engine.pyu_register_extensions s"   c Cst\}}}djd|D}t}tjddt||f}x4dD],}y|j|WqZtk rYqZXqZW|jdd d d d x|D]}||qW|jd ddd d d ddd||fS(uThis returns an instance of optparse.OptionParser with all the extensions registered and options set. This wraps ``pep8.get_parser``. u, cSsg|]}d|qS(u%s: %s((u.0uext((u./home/icordasc/sandbox/flake8/flake8/engine.pyu (s uflake8u %s (%s) %su--repeatu --testsuiteu --doctestu --exit-zerouactionu store_trueuhelpu)exit with code 0 even if there are errorsu--install-hookudefaultu1Install the appropriate hook for this repository.udestu install_hook(u--repeatu --testsuiteu --doctestF( u_register_extensionsujoinuget_python_versionupep8u get_parseru __version__u remove_optionu ValueErroru add_optionuFalse(u extensionsu parser_hooksu options_hooksudetailsupython_versionuparseruoptu parser_hook((u./home/icordasc/sandbox/flake8/flake8/engine.pyu get_parser#s$      cBs)|EeZejZddddZdS(icCsn|jjrtd|n|j|d|d|j}td|jDrXdS|jd|d|S(u'Run all checks on a Python source file.u checking %sulinesuoptionscss|]}t|VqdS(N(u _flake8_noqa(u.0uline((u./home/icordasc/sandbox/flake8/flake8/engine.pyu Gsiuexpectedu line_offset(uoptionsuverboseuprintu checker_classuanyulinesu check_all(uselfufilenameulinesuexpectedu line_offsetufchecker((u./home/icordasc/sandbox/flake8/flake8/engine.pyu input_file@s N(u__name__u __module__upep8uCheckeru checker_classuNoneu input_file(u __locals__((u./home/icordasc/sandbox/flake8/flake8/engine.pyu StyleGuide<s  u StyleGuidecKsGt\|d<}t|}|j}x|D]}||q/W|S(ubParse the options and configure the checker. This returns a sub-class of ``pep8.StyleGuide``.uparser(u get_parseru StyleGuideuoptions(ukwargsu options_hooksu styleguideuoptionsu options_hook((u./home/icordasc/sandbox/flake8/flake8/engine.pyuget_style_guideLs    cCs#dtjtjtjfS(Nu %s %s on %s(uplatformupython_implementationupython_versionusystem(((u./home/icordasc/sandbox/flake8/flake8/engine.pyuget_python_versionWs(ureuplatformupep8uflake8u __version__u flake8.utilu OrderedSetucompileuIusearchu _flake8_noqau_register_extensionsu get_parseru StyleGuideuget_style_guideuget_python_version(((u./home/icordasc/sandbox/flake8/flake8/engine.pyus      flake8-2.1.0/flake8/__pycache__/__init__.cpython-32.pyc0000644000175000001440000000025112161467632023403 0ustar icordascusers00000000000000l (Qc@s dZdS(u2.0N(u __version__(((u0/home/icordasc/sandbox/flake8/flake8/__init__.pyusflake8-2.1.0/flake8/__pycache__/main.cpython-32.pyc0000644000175000001440000001043412161467632022574 0ustar icordascusers00000000000000l (Qc@sddlZddlZddlZddlmZejjdr[ejjdZ n0ejj ej dpejjddZ dZ ddd Z ddd ZGd d ejZdS(iN(uget_style_guideuwinu ~\.flake8uXDG_CONFIG_HOMEu ~/.configuflake8cCstdddt}|j}|jrAddlm}|n|j}|j}|jrl|jn|j r|j n|j r|j rt jjt|j dn|jstdqndS( u.Parse options and run checks on Python source.u parse_argvu config_filei(u install_hooku iNT(uget_style_guideuTrueuDEFAULT_CONFIGuoptionsu install_hooku flake8.hooksu check_filesu statisticsuprint_statisticsu benchmarkuprint_benchmarku total_errorsucountusysustderruwriteustru exit_zerou SystemExit(u flake8_styleuoptionsu install_hookureport((u,/home/icordasc/sandbox/flake8/flake8/main.pyumains              icCs(tdtd|d|}|j|S(u Checks a file using pep8 and pyflakes by default and mccabe optionally. :param str path: path to the file to be checked :param tuple ignore: (optional), error and warning codes to be ignored :param int complexity: (optional), enables the mccabe check for values > 0 u config_fileuignoreumax_complexity(uget_style_guideuDEFAULT_CONFIGu input_file(upathuignoreu complexityu flake8_style((u,/home/icordasc/sandbox/flake8/flake8/main.pyu check_file,scCs4tdtd|d|}|jdd|jS(u Checks code using pep8 and pyflakes by default and mccabe optionally. :param str code: code to be checked :param tuple ignore: (optional), error and warning codes to be ignored :param int complexity: (optional), enables the mccabe check for values > 0 u config_fileuignoreumax_complexityu-ulines(uget_style_guideuDEFAULT_CONFIGu input_fileu splitlines(ucodeuignoreu complexityu flake8_style((u,/home/icordasc/sandbox/flake8/flake8/main.pyu check_code9scBsD|EeZdZdZgZdZdZdZdZdS(uhThe :class:`Flake8Command` class is used by setuptools to perform checks on registered modules. u.Run flake8 on modules registered in setuptoolscCsdS(N((uself((u,/home/icordasc/sandbox/flake8/flake8/main.pyuinitialize_optionsMscCsdS(N((uself((u,/home/icordasc/sandbox/flake8/flake8/main.pyufinalize_optionsPsccsp|jjr=x.|jjD]}|jdtjjVqWn|jjrlx |jjD]}d|VqVWndS(Nu.u%s.py(u distributionupackagesureplaceuosupathusepu py_modules(uselfupackageufilename((u,/home/icordasc/sandbox/flake8/flake8/main.pyudistribution_filesSs   cCsCtdt}|j}|j|}t|jdkdS(Nu config_filei(uget_style_guideuDEFAULT_CONFIGudistribution_filesu check_filesu SystemExitu total_errors(uselfu flake8_styleupathsureport((u,/home/icordasc/sandbox/flake8/flake8/main.pyurun\s N( u__name__u __module__u__doc__u descriptionu user_optionsuinitialize_optionsufinalize_optionsudistribution_filesurun(u __locals__((u,/home/icordasc/sandbox/flake8/flake8/main.pyu Flake8CommandEs    u Flake8Command(i(i(uosusysu setuptoolsu flake8.engineuget_style_guideuplatformu startswithupathu expanduseruDEFAULT_CONFIGujoinugetenvumainu check_fileu check_codeuCommandu Flake8Command(((u,/home/icordasc/sandbox/flake8/flake8/main.pyus        flake8-2.1.0/flake8/__pycache__/util.cpython-32.pyc0000644000175000001440000000317112161467632022625 0ustar icordascusers00000000000000l *Qc @syddlZejZWn]ek rxddlZdejjkrkdej_edej_ndZYnXGdde Z dS(iNudecorator_listcCs|jS(N(u decorators(us((u,/home/icordasc/sandbox/flake8/flake8/util.pyu sccs|js dSxz|jD]o}t||d}t|tjrI|Vqt|trx+|D] }t|tjr_|Vq_q_WqqWdS(u Yield all direct child nodes of *node*, that is, all fields that are nodes and all items of fields that are lists of nodes. N(u_fieldsugetattruNoneu isinstanceuastuASTulist(unodeunameufielduitem((u,/home/icordasc/sandbox/flake8/flake8/util.pyuiter_child_nodess  cBs#|EeZdZdZdZdS(uList without duplicates.cCs ||kr|j|ndS(N(uappend(uselfuvalue((u,/home/icordasc/sandbox/flake8/flake8/util.pyuadd#s N((u__name__u __module__u__doc__u __slots__uadd(u __locals__((u,/home/icordasc/sandbox/flake8/flake8/util.pyu OrderedSets u OrderedSet(( uastuiter_child_nodesu ImportErroru_astuClassDefu_fieldsudecorator_listupropertyu FunctionDefulistu OrderedSet(((u,/home/icordasc/sandbox/flake8/flake8/util.pyus     flake8-2.1.0/flake8/run.py0000644000175000001440000000041712161467632016174 0ustar icordascusers00000000000000 """ Implementation of the command-line I{flake8} tool. """ from flake8.hooks import git_hook, hg_hook # noqa from flake8.main import check_code, check_file, Flake8Command # noqa from flake8.main import main if __name__ == '__main__': main() flake8-2.1.0/flake8/hooks.pyc0000644000175000001440000001321012161467632016651 0ustar icordascusers00000000000000 ZOQc@sddklZddkZddkZddklZlZyddklZWn#e j oddklZnXddk l Z l Z ddk lZdededZdZd Zd Zd Zd Zd ZdZdS(i(twith_statementN(tPopentPIPE(t ConfigParser(t get_parsertget_style_guide(tDEFAULT_CONFIGc Csd}|o|idd}nt|do|id}nt|\}}}tdtd|d|}|ig}|D]!} | id o || qq~} |o| iSd S( sVThis is the function used by the git hook. :param int complexity: (optional), any value > 0 enables complexity checking with mccabe :param bool strict: (optional), if True, this returns the total number of errors which will cause the hook to fail :param str ignore: (optional), a comma-separated list of errors and warnings to ignore :param bool lazy: (optional), allows for the instances where you don't add the files to the index before running a commit, e.g., git commit -a :returns: total number of errors if strict is True, otherwise 0 s(git diff-index --cached --name-only HEADs --cached ttsplitt,t config_filetignoretmax_complexitys.pyi( treplacethasattrRtrunRRt check_filestendswitht total_errors( t complexitytstrictR tlazytgitcmdt_tfiles_modifiedt flake8_stylet_[1]tftreport((s-/home/icordasc/sandbox/flake8/flake8/hooks.pytgit_hooks 'c Ks|idddd}|idddt}|idddt}|tjo t}nt||}td|d|}|i|}|o|iSd S( sThis is the function executed directly by Mercurial as part of the hook. This is never called directly by the user, so the parameters are undocumented. If you would like to learn more about them, please feel free to read the official Mercurial documentation. tflake8RtdefaultiRtconfigR R i(R t configbooltTrueRt _get_filesRRR( tuitrepotkwargsRRR tpathsRR((s-/home/icordasc/sandbox/flake8/flake8/hooks.pythg_hook3s  cCst|idtdt}|i\}}|ig}|iD]}||iqG~g}|iD]}||iqq~fS(Ntstdouttstderr(RRRt communicatet returncodet splitlineststrip(tcommandtpR)R*Rtlinet_[2]((s-/home/icordasc/sandbox/flake8/flake8/hooks.pyRKs0ckst}xt||dt|D]}x~||iD]l}tii|i|}||jptii| oq>n|i ||i do |Vq>q>Wq'WdS(Ntnodes.py( tsettrangetlentfilestostpathtjointroottexiststaddR(R%R&tseentrevtfile_((s-/home/icordasc/sandbox/flake8/flake8/hooks.pyR#Rs ! cCsXtiido)tiidptidndStiidodSdS(Ns.gits .git/hookss.git/hooks/pre-commits.hgs.hg/hgrcR(R8R9tisdirtmkdir(((s-/home/icordasc/sandbox/flake8/flake8/hooks.pytfind_vcs^ss#!/usr/bin/env python import sys import os from flake8.hooks import git_hook COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10) STRICT = os.getenv('FLAKE8_STRICT', False) if __name__ == '__main__': sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT)) cCsktii|pt|dint}|it|d|idp|idn|i ddp|i dddn|i ddp|i dddn|idp|idn|i ddp)|i ddt ti d d n|i dd p#|i dd ti d t n|it|ddS( Nsw+trthookstcommitspython:flake8.hooks.hg_hooktqrefreshRRtFLAKE8_COMPLEXITYi Rt FLAKE8_STRICT(R8R9tisfiletopentcloseRtreadfpt has_sectiont add_sectiont has_optionR4tstrtgetenvtFalsetwrite(R9tc((s-/home/icordasc/sandbox/flake8/flake8/hooks.pyt_install_hg_hookvs" )#cCst}|p4t}tiid|itidnd}d|joMt|dii }z|~}|it WdQXt i |dn"d|jot |nd}ti|dS(NseError: could not find either a git or mercurial directory. Please re-run this in a proper repository.iitgitsw+ithg(RCRtsysR*RTt print_helptexitRKt__exit__t __enter__t git_hook_fileR8tchmodRV(tvcsR0tstatusRtfd((s-/home/icordasc/sandbox/flake8/flake8/hooks.pyt install_hooks    & (t __future__RR8RYt subprocessRRt configparserRt ImportErrort flake8.engineRRt flake8.mainRRStNoneRR(RR#RCR^RVRc(((s-/home/icordasc/sandbox/flake8/flake8/hooks.pyts"  $    flake8-2.1.0/flake8/engine.py0000644000175000001440000000630212161467632016634 0ustar icordascusers00000000000000# -*- coding: utf-8 -*- import re import platform import pep8 from flake8 import __version__ from flake8.util import OrderedSet _flake8_noqa = re.compile(r'flake8[:=]\s*noqa', re.I).search def _register_extensions(): """Register all the extensions.""" extensions = OrderedSet() extensions.add(('pep8', pep8.__version__)) parser_hooks = [] options_hooks = [] try: from pkg_resources import iter_entry_points except ImportError: pass else: for entry in iter_entry_points('flake8.extension'): checker = entry.load() pep8.register_check(checker, codes=[entry.name]) extensions.add((checker.name, checker.version)) if hasattr(checker, 'add_options'): parser_hooks.append(checker.add_options) if hasattr(checker, 'parse_options'): options_hooks.append(checker.parse_options) return extensions, parser_hooks, options_hooks def get_parser(): """This returns an instance of optparse.OptionParser with all the extensions registered and options set. This wraps ``pep8.get_parser``. """ (extensions, parser_hooks, options_hooks) = _register_extensions() details = ', '.join(['%s: %s' % ext for ext in extensions]) python_version = get_python_version() parser = pep8.get_parser('flake8', '%s (%s) %s' % ( __version__, details, python_version )) for opt in ('--repeat', '--testsuite', '--doctest'): try: parser.remove_option(opt) except ValueError: pass parser.add_option('--exit-zero', action='store_true', help="exit with code 0 even if there are errors") for parser_hook in parser_hooks: parser_hook(parser) parser.add_option('--install-hook', default=False, action='store_true', help='Install the appropriate hook for this ' 'repository.', dest='install_hook') return parser, options_hooks class StyleGuide(pep8.StyleGuide): # Backward compatibility pep8 <= 1.4.2 checker_class = pep8.Checker def input_file(self, filename, lines=None, expected=None, line_offset=0): """Run all checks on a Python source file.""" if self.options.verbose: print('checking %s' % filename) fchecker = self.checker_class( filename, lines=lines, options=self.options) # Any "# flake8: noqa" line? if any(_flake8_noqa(line) for line in fchecker.lines): return 0 return fchecker.check_all(expected=expected, line_offset=line_offset) def get_style_guide(**kwargs): """Parse the options and configure the checker. This returns a sub-class of ``pep8.StyleGuide``.""" kwargs['parser'], options_hooks = get_parser() styleguide = StyleGuide(**kwargs) options = styleguide.options for options_hook in options_hooks: options_hook(options) return styleguide def get_python_version(): # The implementation isn't all that important. try: impl = platform.python_implementation() + " " except AttributeError: # Python 2.5 impl = '' return '%s%s on %s' % (impl, platform.python_version(), platform.system()) flake8-2.1.0/flake8/engine.pyc0000644000175000001440000000717612166032716017005 0ustar icordascusers00000000000000 oQc@sddlZddlZddlZddlmZddlmZejdejj Z dZ dZ dej fdYZ d Zd ZdS( iN(t __version__(t OrderedSetsflake8[:=]\s*noqacCst}|jdtjfg}g}yddlm}Wntk rRnXx|dD]}|j}tj|d|j g|j|j |j ft |dr|j |j nt |dr`|j |jq`q`W|||fS(sRegister all the extensions.tpep8i(titer_entry_pointssflake8.extensiontcodest add_optionst parse_options(RtaddRRt pkg_resourcesRt ImportErrortloadtregister_checktnametversionthasattrtappendRR(t extensionst parser_hookst options_hooksRtentrytchecker((s./flake8/engine.pyt_register_extensions s"   c Cst\}}}djg|D]}d|^q}t}tjddt||f}x3dD]+}y|j|Wqgtk rqgXqgW|jdd d d d x|D]}||qW|jd dt d d d ddd||fS(sThis returns an instance of optparse.OptionParser with all the extensions registered and options set. This wraps ``pep8.get_parser``. s, s%s: %stflake8s %s (%s) %ss--repeats --testsuites --doctests --exit-zerotactiont store_truethelps)exit with code 0 even if there are errorss--install-hooktdefaults1Install the appropriate hook for this repository.tdestt install_hook(s--repeats --testsuites --doctest( Rtjointget_python_versionRt get_parserRt remove_optiont ValueErrort add_optiontFalse( RRRtexttdetailstpython_versiontparsertoptt parser_hook((s./flake8/engine.pyR#s$&     t StyleGuidecBs#eZejZddddZRS(icCsi|jjrd|GHn|j|d|d|j}td|jDrSdS|jd|d|S(s'Run all checks on a Python source file.s checking %stlinestoptionscss|]}t|VqdS(N(t _flake8_noqa(t.0tline((s./flake8/engine.pys Gsitexpectedt line_offset(R,tverboset checker_classtanyR+t check_all(tselftfilenameR+R0R1tfchecker((s./flake8/engine.pyt input_file@s  N(t__name__t __module__RtCheckerR3tNoneR9(((s./flake8/engine.pyR*<s cKsGt\|d<}t|}|j}x|D]}||q/W|S(sbParse the options and configure the checker. This returns a sub-class of ``pep8.StyleGuide``.R'(RR*R,(tkwargsRt styleguideR,t options_hook((s./flake8/engine.pytget_style_guideLs    cCsKytjd}Wntk r-d}nXd|tjtjfS(Nt ts %s%s on %s(tplatformtpython_implementationtAttributeErrorR&tsystem(timpl((s./flake8/engine.pyRWs   (treRDRRRt flake8.utilRtcompiletItsearchR-RRR*RAR(((s./flake8/engine.pyts      flake8-2.1.0/flake8/main.pyc0000644000175000001440000000744112161467632016463 0ustar icordascusers00000000000000 0YQc@sddkZddkZddkZddklZeiidoeiidZ n2eii ei dpeiiddZ dZ d dd Z ddd Zd eifd YZdS(iN(tget_style_guidetwins ~\.flake8tXDG_CONFIG_HOMEs ~/.configtflake8cCstdtdt}|i}|ioddkl}|n|i}|i}|io|in|i o|i n|i oI|i o!t iit|i dn|iptdqndS(s.Parse options and run checks on Python source.t parse_argvt config_filei(t install_hooks iN(RtTruetDEFAULT_CONFIGtoptionsRt flake8.hookst check_filest statisticstprint_statisticst benchmarktprint_benchmarkt total_errorstcounttsyststderrtwritetstrt exit_zerot SystemExit(t flake8_styleR Rtreport((s,/home/icordasc/sandbox/flake8/flake8/main.pytmains          ! cCs(tdtd|d|}|i|S(sChecks a file using pep8 and pyflakes by default and mccabe optionally. :param str path: path to the file to be checked :param tuple ignore: (optional), error and warning codes to be ignored :param int complexity: (optional), enables the mccabe check for values > 0 Rtignoretmax_complexity(RRt input_file(tpathRt complexityR((s,/home/icordasc/sandbox/flake8/flake8/main.pyt check_file,scCs7tdtd|d|}|idd|itS(s Checks code using pep8 and pyflakes by default and mccabe optionally. :param str code: code to be checked :param tuple ignore: (optional), error and warning codes to be ignored :param int complexity: (optional), enables the mccabe check for values > 0 RRRtlinesN(RRRtNonet splitlinesR(tcodeRRR((s,/home/icordasc/sandbox/flake8/flake8/main.pyt check_code9st Flake8CommandcBs>eZdZdZgZdZdZdZdZRS(shThe :class:`Flake8Command` class is used by setuptools to perform checks on registered modules. s.Run flake8 on modules registered in setuptoolscCsdS(N((tself((s,/home/icordasc/sandbox/flake8/flake8/main.pytinitialize_optionsMscCsdS(N((R'((s,/home/icordasc/sandbox/flake8/flake8/main.pytfinalize_optionsPsccst|iio2x/|iiD]}|idtiiVqWn|iio$x!|iiD]}d|VqYWndS(Nt.s%s.py(t distributiontpackagestreplacetosRtsept py_modules(R'tpackagetfilename((s,/home/icordasc/sandbox/flake8/flake8/main.pytdistribution_filesSs    cCsCtdt}|i}|i|}t|idjdS(NRi(RRR3R RR(R'RtpathsR((s,/home/icordasc/sandbox/flake8/flake8/main.pytrun\s ( t__name__t __module__t__doc__t descriptiont user_optionsR(R)R3R5(((s,/home/icordasc/sandbox/flake8/flake8/main.pyR&Es   (((R.Rt setuptoolst flake8.engineRtplatformt startswithRt expanduserRtjointgetenvRR R%tCommandR&(((s,/home/icordasc/sandbox/flake8/flake8/main.pyts        flake8-2.1.0/flake8/_pyflakes.pyc0000644000175000001440000000516012166066505017507 0ustar icordascusers00000000000000 Qc@sHddlZddlZdZedejjfdYZdS(iNcCstgdD]}|jd d d^q }xattjjD]J\}}|djrH|jrHd|j|d|jf|_ qHqHWd S(s%Add error codes to Pyflakes messages.sF401 UnusedImportsF402 ImportShadowedByLoopVarsF403 ImportStarUsedsF404 LateFutureImportsF810 RedefinedsF811 RedefinedWhileUnusedsF812 RedefinedInListCompsF821 UndefinedNamesF822 UndefinedExportsF823 UndefinedLocalsF831 DuplicateArgumentsF841 UnusedVariableNiis%s %stF999( sF401 UnusedImportsF402 ImportShadowedByLoopVarsF403 ImportStarUsedsF404 LateFutureImportsF810 RedefinedsF811 RedefinedWhileUnusedsF812 RedefinedInListCompsF821 UndefinedNamesF822 UndefinedExportsF823 UndefinedLocalsF831 DuplicateArgumentsF841 UnusedVariable( tdicttsplittvarstpyflakestmessagestitemstisuppertmessagetgett flake8_msg(tlinetcodestnametobj((s1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pytpatch_pyflakess ,"t FlakesCheckercBsDeZdZdZejZedZedZ dZ RS(s=Subclass the Pyflakes checker to conform with the flake8 API.RcCs'|jddd|jjddS(Ns --builtinsthelps&define more built-ins, comma separatedtbuiltins(t add_optiontconfig_optionstappend(tclstparser((s1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyt add_options"s cCs1|jr-|jj|jjd|_ndS(Nt,(RtbuiltInstunionR(Rtoptions((s1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyt parse_options(s ccsKxD|jD]9}t|dd}|j||j|j|jfVq WdS(Ntcoli(RtgetattrtlinenoR t message_argst __class__(tselftmR((s1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pytrun-s( t__name__t __module__t__doc__R Rt __version__tversiont classmethodRRR%(((s1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyRs  (Rtpyflakes.checkerRtcheckertCheckerR(((s1/home/icordasc/sandbox/flake8/flake8/_pyflakes.pyts   flake8-2.1.0/flake8/_pyflakes.py0000644000175000001440000000277312165553306017352 0ustar icordascusers00000000000000# -*- coding: utf-8 -*- import pyflakes import pyflakes.checker def patch_pyflakes(): """Add error codes to Pyflakes messages.""" codes = dict([line.split()[::-1] for line in ( 'F401 UnusedImport', 'F402 ImportShadowedByLoopVar', 'F403 ImportStarUsed', 'F404 LateFutureImport', 'F810 Redefined', # XXX Obsolete? 'F811 RedefinedWhileUnused', 'F812 RedefinedInListComp', 'F821 UndefinedName', 'F822 UndefinedExport', 'F823 UndefinedLocal', 'F831 DuplicateArgument', 'F841 UnusedVariable', )]) for name, obj in vars(pyflakes.messages).items(): if name[0].isupper() and obj.message: obj.flake8_msg = '%s %s' % (codes.get(name, 'F999'), obj.message) patch_pyflakes() class FlakesChecker(pyflakes.checker.Checker): """Subclass the Pyflakes checker to conform with the flake8 API.""" name = 'pyflakes' version = pyflakes.__version__ @classmethod def add_options(cls, parser): parser.add_option('--builtins', help="define more built-ins, comma separated") parser.config_options.append('builtins') @classmethod def parse_options(cls, options): if options.builtins: cls.builtIns = cls.builtIns.union(options.builtins.split(',')) def run(self): for m in self.messages: col = getattr(m, 'col', 0) yield m.lineno, col, (m.flake8_msg % m.message_args), m.__class__ flake8-2.1.0/MANIFEST.in0000644000175000001440000000012212161467632015373 0ustar icordascusers00000000000000include *.rst include CONTRIBUTORS.txt include LICENSE recursive-include flake8 * flake8-2.1.0/setup.cfg0000644000175000001440000000007312233022416015446 0ustar icordascusers00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 flake8-2.1.0/setup.py0000644000175000001440000000332112226402550015341 0ustar icordascusers00000000000000# -*- coding: utf-8 -*- from __future__ import with_statement from setuptools import setup def get_version(fname='flake8/__init__.py'): with open(fname) as f: for line in f: if line.startswith('__version__'): return eval(line.split('=')[-1]) def get_long_description(): descr = [] for fname in ('README.rst', 'CHANGES.rst'): with open(fname) as f: descr.append(f.read()) return '\n\n'.join(descr) setup( name="flake8", license="MIT", version=get_version(), description="the modular source code checker: pep8, pyflakes and co", long_description=get_long_description(), author="Tarek Ziade", author_email="tarek@ziade.org", maintainer="Ian Cordasco", maintainer_email="graffatcolmingov@gmail.com", url="http://bitbucket.org/tarek/flake8", packages=["flake8", "flake8.tests"], install_requires=[ "pyflakes >= 0.7.3", "pep8 >= 1.4.6", "mccabe >= 0.2.1", ], entry_points={ 'distutils.commands': ['flake8 = flake8.main:Flake8Command'], 'console_scripts': ['flake8 = flake8.main:main'], 'flake8.extension': [ 'F = flake8._pyflakes:FlakesChecker', ], }, classifiers=[ "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance", ], tests_require=['nose', 'mock'], test_suite='nose.collector', )