flake8-2.5.4/00007550_j0000000000012657145314012571 5ustar ian770800000000000000flake8-2.5.4/CHANGES.rst00006440_j0000002210612657145224014374 0ustar ian770800000000000000CHANGES ======= 2.5.4 - 2016-02-11 ------------------ - **Bug** Missed an attribute rename during the v2.5.3 release. 2.5.3 - 2016-02-11 ------------------ - **Bug** Actually parse ``output_file`` and ``enable_extensions`` from config files 2.5.2 - 2016-01-30 ------------------ - **Bug** Parse ``output_file`` and ``enable_extensions`` from config files - **Improvement** Raise upper bound on mccabe plugin to allow for version 0.4.0 2.5.1 - 2015-12-08 ------------------ - **Bug** Properly look for ``.flake8`` in current working directory (`GitLab#103`_) - **Bug** Monkey-patch ``pep8.stdin_get_value`` to cache the actual value in stdin. This helps plugins relying on the function when run with multiprocessing. (`GitLab#105`_, `GitLab#107`_) .. _GitLab#103: https://gitlab.com/pycqa/flake8/issues/103 .. _GitLab#105: https://gitlab.com/pycqa/flake8/issues/105 .. _GitLab#107: https://gitlab.com/pycqa/flake8/issues/107 2.5.0 - 2015-10-26 ------------------ - **Improvement** Raise cap on PyFlakes for Python 3.5 support - **Improvement** Avoid deprecation warnings when loading extensions (`GitLab#59`_, `GitLab#90`_) - **Improvement** Separate logic to enable "off-by-default" extensions (`GitLab#67`_) - **Bug** Properly parse options to setuptools Flake8 command (`GitLab!41`_) - **Bug** Fix exceptions when output on stdout is truncated before Flake8 finishes writing the output (`GitLab#69`_) - **Bug** Fix error on OS X where Flake8 can no longer acquire or create new semaphores (`GitLab#74`_) .. _GitLab!41: https://gitlab.com/pycqa/flake8/merge_requests/41 .. _GitLab#59: https://gitlab.com/pycqa/flake8/issues/59 .. _GitLab#67: https://gitlab.com/pycqa/flake8/issues/67 .. _GitLab#69: https://gitlab.com/pycqa/flake8/issues/69 .. _GitLab#74: https://gitlab.com/pycqa/flake8/issues/74 .. _GitLab#90: https://gitlab.com/pycqa/flake8/issues/90 2.4.1 - 2015-05-18 ------------------ - **Bug** Do not raise a ``SystemError`` unless there were errors in the setuptools command. (`GitLab#39`_, `GitLab!23`_) - **Bug** Do not verify dependencies of extensions loaded via entry-points. - **Improvement** Blacklist versions of pep8 we know are broken .. _GitLab#39: https://gitlab.com/pycqa/flake8/issues/39 .. _GitLab!23: https://gitlab.com/pycqa/flake8/merge_requests/23 2.4.0 - 2015-03-07 ------------------ - **Bug** Print filenames when using multiprocessing and ``-q`` option. (`GitLab#31`_) - **Bug** Put upper cap on dependencies. The caps for 2.4.0 are: - ``pep8 < 1.6`` (Related to `GitLab#35`_) - ``mccabe < 0.4`` - ``pyflakes < 0.9`` See also `GitLab#32`_ - **Bug** Files excluded in a config file were not being excluded when flake8 was run from a git hook. (`GitHub#2`_) - **Improvement** Print warnings for users who are providing mutually exclusive options to flake8. (`GitLab#8`_, `GitLab!18`_) - **Feature** Allow git hook configuration to live in ``.git/config``. See the updated `VCS hooks docs`_ for more details. (`GitLab!20`_) .. _GitHub#2: https://github.com/pycqa/flake8/pull/2 .. _GitLab#8: https://gitlab.com/pycqa/flake8/issues/8 .. _GitLab#31: https://gitlab.com/pycqa/flake8/issues/31 .. _GitLab#32: https://gitlab.com/pycqa/flake8/issues/32 .. _GitLab#35: https://gitlab.com/pycqa/flake8/issues/35 .. _GitLab!18: https://gitlab.com/pycqa/flake8/merge_requests/18 .. _GitLab!20: https://gitlab.com/pycqa/flake8/merge_requests/20 .. _VCS hooks docs: https://flake8.readthedocs.org/en/latest/vcs.html 2.3.0 - 2015-01-04 ------------------ - **Feature**: Add ``--output-file`` option to specify a file to write to instead of ``stdout``. - **Bug** Fix interleaving of output while using multiprocessing (`GitLab#17`_) .. _GitLab#17: https://gitlab.com/pycqa/flake8/issues/17 2.2.5 - 2014-10-19 ------------------ - Flush standard out when using multiprocessing - Make the check for "# flake8: noqa" more strict 2.2.4 - 2014-10-09 ------------------ - Fix bugs triggered by turning multiprocessing on by default (again) Multiprocessing is forcibly disabled in the following cases: - Passing something in via stdin - Analyzing a diff - Using windows - Fix --install-hook when there are no config files present for pep8 or flake8. - Fix how the setuptools command parses excludes in config files - Fix how the git hook determines which files to analyze (Thanks Chris Buccella!) 2.2.3 - 2014-08-25 ------------------ - Actually turn multiprocessing on by default 2.2.2 - 2014-07-04 ------------------ - Re-enable multiprocessing by default while fixing the issue Windows users were seeing. 2.2.1 - 2014-06-30 ------------------ - Turn off multiple jobs by default. To enable automatic use of all CPUs, use ``--jobs=auto``. Fixes #155 and #154. 2.2.0 - 2014-06-22 ------------------ - New option ``doctests`` to run Pyflakes checks on doctests too - New option ``jobs`` to launch multiple jobs in parallel - Turn on using multiple jobs by default using the CPU count - Add support for ``python -m flake8`` on Python 2.7 and Python 3 - Fix Git and Mercurial hooks: issues #88, #133, #148 and #149 - Fix crashes with Python 3.4 by upgrading dependencies - Fix traceback when running tests with Python 2.6 - Fix the setuptools command ``python setup.py flake8`` to read the project configuration 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 if 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.5.4/CONTRIBUTORS.txt00006440_j0000000066612520516167015274 0ustar ian770800000000000000Project 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 Morton - Michael McNeil Forbes - Christian Long - Tyrel Souza - Corey Farwell flake8-2.5.4/flake8/00007550_j0000000000012657145314013743 5ustar ian770800000000000000flake8-2.5.4/flake8/__init__.py00006440_j0000000002612657145233016052 0ustar ian770800000000000000__version__ = '2.5.4' flake8-2.5.4/flake8/__init__.pyc00006440_j0000000024712641044042016207 0ustar ian770800000000000000 oVc@s dZdS(s2.5.1N(t __version__(((s0/Users/ian7708/sandbox/flake8/flake8/__init__.pytsflake8-2.5.4/flake8/__main__.py00006440_j0000000011512415552077016032 0ustar ian770800000000000000from flake8.main import main # python -m flake8 (with Python >= 2.7) main() flake8-2.5.4/flake8/__pycache__/00007550_j0000000000012657145314016153 5ustar ian770800000000000000flake8-2.5.4/flake8/__pycache__/__init__.cpython-34.pyc00006440_j0000000023212641043677022335 0ustar ian770800000000000000 oV@s dZdS)z2.5.1N) __version__rr0/Users/ian7708/sandbox/flake8/flake8/__init__.pysflake8-2.5.4/flake8/__pycache__/_pyflakes.cpython-34.pyc00006440_j0000001035412641043677022561 0ustar ian770800000000000000 "AV @syddlmZWnek r(Yn XejddlZddlZddlZddlZddZeGdddej j Z dS)) demandimportNcCstdddD}xattjjD]J\}}|djr/|jr/d|j|d|jf|_q/q/WdS)z%Add error codes to Pyflakes messages.cSs)g|]}|jdddqS)N)split).0liner1/Users/ian7708/sandbox/flake8/flake8/_pyflakes.py s z"patch_pyflakes..F401 UnusedImportF402 ImportShadowedByLoopVarF403 ImportStarUsedF404 LateFutureImportF810 RedefinedF811 RedefinedWhileUnusedF812 RedefinedInListCompF821 UndefinedNameF822 UndefinedExportF823 UndefinedLocalF831 DuplicateArgumentF841 UnusedVariablerz%s %sZF999N) r r r rrrrrrrrr) dictvarspyflakesmessagesitemsisuppermessageget flake8_msg)codesnameobjrrr patch_pyflakess   "r#csgeZdZdZdZejZfddZe ddZ e ddZ d d Z S) FlakesCheckerz=Subclass the Pyflakes checker to conform with the flake8 API.rcstjd|j}fdd|jD}|rGd}nx]|jD]RdkrQjrQd}fdd|D}|rd}qqQqQWtt|j|d|dS) Nrcs1g|]'}|dkrj|r|qS)) startswith)rinclude)filenamerr r /s z*FlakesChecker.__init__..Tr%Fcs%g|]}|jr|qSr)r&)rr')excluderr r 7s  withDoctest) pep8normalize_pathsr*include_in_doctestexclude_from_doctestr&superr$__init__)selftreer(r*Z included_byZ overlaped_by) __class__)r)r(r r0,s  zFlakesChecker.__init__c Cs|jddd|jddddddd |jd dd d d dddd|jddd d ddddd|jjddddgdS)Nz --builtinshelpz&define more built-ins, comma separatedz --doctestsdefaultFaction store_truezcheck syntax of the doctestsz--include-in-doctestr%destr-z Run doctests only on these filestypestringz--exclude-from-doctestr.z&Skip these files when running doctestsbuiltinsdoctestszinclude-in-doctestzexclude-from-doctest) add_optionconfig_optionsextend)clsparserrrr add_options@s zFlakesChecker.add_optionscCs|jr-|jj|jjd|_n|j|_g}xh|jjdD]T}|dkrjqRn|jtj ddfs|j d|qR|j |qRWt j dj ||_g}xh|jjdD]T}|dkrqn|jtj ddfs%|j d|q|j |qWt j dj ||_t|jjt|j}|rtd|ndS)N,r%z./z~/z"%s" was specified in both the include-in-doctest and exclude-from-doctest options. You are not allowed to specify it in both for doctesting.)r;ZbuiltInsunionrr<r*r-r&ossepappendr+r,joinr.set intersection ValueError)r@optionsZincluded_filesZ included_fileZexcluded_filesZ excluded_fileZinc_excrrr parse_optionsRs2 $   zFlakesChecker.parse_optionsccsKxD|jD]9}t|dd}|j||j|j|jfVq WdS)Ncolr)rgetattrlinenorZ message_argsr3)r1mrNrrr runuszFlakesChecker.run) __name__ __module__ __qualname____doc__r!r __version__versionr0 classmethodrBrMrRrr)r3r r$'s  #r$) Z mercurialr ImportErrordisablerEr+rZpyflakes.checkerr#checkerCheckerr$rrrr s       flake8-2.5.4/flake8/__pycache__/callbacks.cpython-34.pyc00006440_j0000000140112547753733022522 0ustar ian770800000000000000 ܬT@s@ddlZddlZddZddZddZdS)NcCs d|j_|jjddS)NT.)values install_hookrargsappend)option option_strvalueparserr 1/Users/ian7708/sandbox/flake8/flake8/callbacks.pyinstall_vcs_hooks r cCstjj|t_dS)N)sysstdoutclose) old_stdoutr r r restore_stdouts rcCs6t|d}tj|}t_tjt|dS)Nw)openrratexitregisterr)rrr r fdrr r r redirect_stdoutsr)rrr rrr r r r s   flake8-2.5.4/flake8/__pycache__/compat.cpython-34.pyc00006440_j0000000105612547753733022074 0ustar ian770800000000000000 T[@s1dZddlZddlZdddZdS)zCompatibility shims for Flake8.N.cCsLtjdkr2|j|r2|t|dStjj|d|SdS)z>Wallpaper over the differences between 2.6 and newer versions.Nstart)rr)sys version_info startswithlenospathrelpath)r rr ./Users/ian7708/sandbox/flake8/flake8/compat.pyr sr )__doc__os.pathr rr r r r rs  flake8-2.5.4/flake8/__pycache__/engine.cpython-34.pyc00006440_j0000002334712641043677022057 0ustar ian770800000000000000 "AV,@sddlZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z mZddlmZejdejjZddd gZejd 7_d d Zd dZddZGdddejZGdddeZdddZddZddZddZddZ e ej!e_!dS)!N) __version__) callbacks)multiprocessing BaseQReport FileQReport QueueReport)utilz\s*# flake8[:=]\s*noqaz.toxz.eggsz*.egg.flake8cCsVt|dr@t|dr@|r1|jn|j}n|jd|}|S)aBased on the version of setuptools load an entry-point correctly. setuptools 11.3 deprecated `require=False` in the call to EntryPoint.load. To load entry points correctly after that without requiring all dependencies be present, the proper way is to call EntryPoint.resolve. This function will provide backwards compatibility for older versions of setuptools while also ensuring we do the right thing for the future. resolverequire)hasattrr r load) entry_pointverify_requirementspluginr./Users/ian7708/sandbox/flake8/flake8/engine.py_load_entry_points  rc Cs7tj}|jdtjfg}g}g}yddlm}Wntk r\YnXx|dD]}t|dd}tj |d|j g|j|j |j ft |dr|j |jnt |d r|j |jnt|d dd krj|j |j qjqjW||||fS) zRegister all the extensions.pep8r)iter_entry_pointszflake8.extensionrFcodes add_options parse_optionsZoff_by_defaultT)r OrderedSetaddrr pkg_resourcesr ImportErrorrregister_checknameversionr appendrrgetattr) extensions parser_hooks options_hooksZ ignored_hooksrentrycheckerrrr_register_extensions,s(  r'c Cst\}}}}djdd|D}t}tjddt||f}x4d%D],}y|j|Wq`tk rYq`Xq`Wtr|j j d |j d d d d ddddn|j dddddx|D]}||qW|j ddddddddddt j |j dddddd d dd dddt j|j d!dd"dd#dd$d d ||_||fS)&zThis returns an instance of optparse.OptionParser with all the extensions registered and options set. This wraps ``pep8.get_parser``. z, css|]}d|VqdS)z%s: %sNr).0extrrr Kszget_parser..flake8z %s (%s) %s--repeat --testsuite --doctestjobsz-jz--jobstypestringdefaultZautohelpzLnumber of jobs to run simultaneously, or 'auto'. This is ignored on Windows.z --exit-zeroaction store_truez)exit with code 0 even if there are errorsz--install-hookFdestZ install_hookz1Install the appropriate hook for this repository.callbackz --output-fileNzRedirect report to a file.nargsz--enable-extensionsenabled_extensionsz:Enable plugins and extensions that are disabled by default)r,r-r.)r'joinget_python_versionr get_parserr remove_option ValueErrorrZconfig_optionsr add_optionrZinstall_vcs_hookredirect_stdoutignored_extensions) r"r#r$ignoreddetailspython_versionparseroptZ parser_hookrrrr>Fs@          r>c@s%eZdZdddddZdS)NoQAStyleGuideNrcCsq|jjrtd|n|j|d|d|j}tdd|jDr[dS|jd|d|S) z'Run all checks on a Python source file.z checking %slinesoptionscss|]}t|VqdS)N) _flake8_noqa)r(linerrrr*{sz,NoQAStyleGuide.input_file..rexpected line_offset)rKverboseprintZ checker_classanyrJZ check_all)selffilenamerJrNrOZfcheckerrrr input_filets zNoQAStyleGuide.input_file)__name__ __module__ __qualname__rUrrrrrIrs rIc@seZdZdZeejgZddZe ddZ e ddZ dd Z d d d Z d d dZd ddZd d dddZd S) StyleGuidezA wrapper StyleGuide object for Flake8 usage. This allows for OSErrors to be caught in the styleguide and special logic to be used to handle those errors. cKs|jdt||_dS)N styleguide)poprI _styleguide)rSkwargsrrr__init__szStyleGuide.__init__cCs |jjS)N)r\rK)rSrrrrKszStyleGuide.optionscCs |jjS)N)r\paths)rSrrrr_szStyleGuide.pathscOsry|||SWnZtk rm}z:|j|jkrK|jtjn|||SWYdd}~XnXdS)aThis will retry the passed function in serial if necessary. In the event that we encounter an OSError with an errno in :attr:`serial_retry_errors`, this function will retry this function using pep8's default Report class which operates in serial. N)OSErrorerrnoserial_retry_errors init_reportrStandardReport)rSfuncargsr]Zoserrrrr _retry_serialszStyleGuide._retry_serialNcCs|j|jjd|S)Nr_)rgr\ check_files)rSr_rrrrhszStyleGuide.check_filescCs|jj|d|S)Nparent)r\excluded)rSrTrirrrrjszStyleGuide.excludedcCs|jj|S)N)r\rc)rSreporterrrrrcszStyleGuide.init_reportrc Cs+|j|jjd|d|d|d|S)NrTrJrNrO)rgr\rU)rSrTrJrNrOrrrrUs  zStyleGuide.input_file)rVrWrX__doc__setraENOSPCrbr^propertyrKr_rgrhrjrcrUrrrrrYs   rY,cCs(|r dd|j|DS|SdS)zSplit and strip and discard empties. Turns the following: A, B, into ["A", "B"]. Credit: Kristian Glass as contributed to pep8 cSs(g|]}|jr|jqSr)strip)r(orrr s z(_parse_multi_options..N)split)rKZ split_tokenrrr_parse_multi_optionss rucCsVtt|dg}tt|j}||8}t|j|j|_dS)NrC)rmr!rur;tupleunionignore)rGrKrCenabledrrr_disable_extensionss rzc Ks4t\|d<}t|}|j}t|d||jrmt|jt rmtj|j|_n|jsg|_n|jj tjt x|D]}||qWt j |r5t stjdnt jrtjdnt j|jrtjdn|jr5tjdq5n|jrJd|_nt j|}t r0|jr0| r0|jjrt|j}n+yt j}Wntk rd}YnX|dkr0||_t}|jrt}|jdkrt}qn|j|}|j|_|j j!|_"q0n|S)zaParse the options and configure the checker. This returns a sub-class of ``pep8.StyleGuide``.rGzGThe multiprocessing module is not available. Ignoring --jobs arguments.zIThe --jobs option is not available on Windows. Ignoring --jobs arguments.z]The --jobs option is not compatible with supplying input using - . Ignoring --jobs arguments.zcThe --diff option was specified with --jobs but they are not compatible. Ignoring --jobs arguments.Nr9)#r>rYrKrzexclude isinstancelistrZnormalize_pathsextend EXTRA_EXCLUDErZwarn_when_using_jobsrwarningswarn is_windowsis_using_stdinr_diffr/force_disable_jobsisdigitint cpu_countNotImplementedErrorrquietrrrcrUZ task_queueputrunner) r]r$rZrKZ options_hookrZn_jobsrkreportrrrget_style_guidesR                rc CsLytjd}Wntk r.d}YnXd|tjtjfS)N r:z %s%s on %s)platformpython_implementationAttributeErrorrFsystem)implrrrr="s   r=csfddS)NcsgtdsT}tjdkr9tj|}ntj|}|_n j}|jS)N cached_stdinr)rr)r sys version_infoioBytesIOStringIOrgetvalue)valuestdin)originalstdin_get_valuerrr,s   z-make_stdin_get_value..stdin_get_valuer)rr)rrrmake_stdin_get_value+s r)r )"rarrrerrrr+rrZflake8.reporterrrrrrcompileIsearchrLrZPROJECT_CONFIGrr'r>rYrIobjectrurzrr=rrrrrrs0       "   ,F = flake8-2.5.4/flake8/__pycache__/hooks.cpython-34.pyc00006440_j0000002003712641043677021726 0ustar ian770800000000000000 V6'@sddlmZddlZddlZddlZddlZddlmZmZddl Z ddl Z yddl m Z Wn"e k rddl m Z YnXddlmZddlmZmZddlmZd%d dd d d Zd d Zd dddZddZddZddddZidd6dd6dd6dd6adddZd Zd!d"Zd#d$ZdS)&)with_statementN)PopenPIPE) ConfigParser)compat) get_parserget_style_guide)DEFAULT_CONFIGFcCs-d}|r!|jdd}nt|drB|jd}nt|\}}}i}|rp||d 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 z?git diff-index --cached --name-only --diff-filter=ACMRTUXB HEADz --cached split,ignorer max_complexity config_filepaths.z git show :%s raw_outputTdecodeFstartwbN ignore_errorsr)replacehasattrr runtempfilemkdtemprr optionsfilenameospathabspath commonprefixrrelpathjoinisdirmakedirspep8filename_matchexcludedappendopenwrite check_filesshutilrmtree total_errors) complexitystrictrlazyZgitcmd_Zfiles_modifiedrtmpdir flake8_style filepatternsZfiles_to_checkfile_Zgitcmd_getstagedoutdirnamerprefixfhreportr?-/Users/ian7708/sandbox/flake8/flake8/hooks.pygit_hooksJ         !$ rAc Ks|jdddd}|jdddd}|jdddd}|jdd dt}t||}i}|r||dr?r?r@hg_hook`s     rHTcCst|jdtdt}|j\}}|r{t|drW|jd}nt|dr{|jd}q{n|sdd|jD}dd|jD}n|j||fS)Nstdoutstderrrzutf-8cSsg|]}|jqSr?)strip).0liner?r?r@ s zrun..cSsg|]}|jqSr?)rK)rLrMr?r?r@rNs )rr r communicaterr splitlines returncode)commandrrprIrJr?r?r@rsrckst}xt||dt|D]}xy||jD]g}tjj|j|}||ks>tjj| rq>n|j ||j dr>|Vq>q>Wq'WdS)Nnodez.py) setrangelenfilesr r!r%rootexistsaddendswith)rFrGseenrevr9r?r?r@rEs $ rEcCsytd\}}}Wntk r-YnX|rtjj|drtjjtjj|ddstjtjj|ddntjj|dddSytd\}}}Wntk rYn7X|rtjj|drtjj|dddSdS) Nzgit rev-parse --git-dirrhooksz pre-commitzhg rootz.hgZhgrcr )rOSErrorr r!r&r%mkdir)r5git_dirZhg_dirr?r?r@find_vcss %# rcr cCstd||fdd\}}}|j}|s;|S|dkr\|jdk}n!|r}|dkr}t|}n|S)Nzgit config --get %s %srTz--booltruez--int)rrKlowerint)optionopt_type convert_typer5Z git_cfg_valuer?r?r@get_git_configs  rjz--intFLAKE8_COMPLEXITYz--bool FLAKE8_STRICT FLAKE8_IGNORE FLAKE8_LAZYcCst|}t|jjddd|dd}|dkrXtjj||}n|dkrt|t r|jdk}n!|r|d krt |}n|S) Nr5rrhriFr z--boolrdz--int) _paramsrjrerr environget isinstanceboolrf)rgrCrhZ param_valuer?r?r@ get_git_params  rta#!/usr/bin/env python import sys from flake8.hooks import git_hook, get_git_param # `get_git_param` will retrieve configuration from your local git config and # then fall back to using the environment variables that the hook has always # supported. # For example, to set the complexity, you'll need to do: # git config flake8.complexity 10 COMPLEXITY = get_git_param('FLAKE8_COMPLEXITY', 10) STRICT = get_git_param('FLAKE8_STRICT', False) IGNORE = get_git_param('FLAKE8_IGNORE', None) LAZY = get_git_param('FLAKE8_LAZY', False) if __name__ == '__main__': sys.exit(git_hook( complexity=COMPLEXITY, strict=STRICT, ignore=IGNORE, lazy=LAZY, )) c Cstjj}tjj|s4t|djnt}|jt|d|j dsr|j dn|j dds|j dddn|j dds|j dddn|j ds|j dn|j dds|j ddt |d d n|j dd sI|j dd |d d n|j ddsz|j dd|ddn|j dds|j dd|dd nt|d}|j|WdQXdS)Nwrr_Zcommitzpython:flake8.hooks.hg_hookZqrefreshrBr2rk r3rlFrrmr r4rn)r rprqr!isfiler,closerreadfp has_section add_section has_optionrUstrr-)r!getenvcfdr?r?r@_install_hg_hooks.  %rc Cst}|sFtd}tjjd|jtjdnd}d|krtjj |r~tjd|nt |d}|jt WdQXtj |t jt jBt jBnd|krt|nd}tj|dS)NrzfError: could not find either a git or mercurial directory. Please re-run this in a proper repository. r gitzError: hook already exists (%s)ruZhg)rcrsysrJr- print_helpexitr r!rZr, git_hook_filechmodstatS_IRWXUS_IRGRPS_IROTHr)ZvcsrSstatusrr?r?r@ install_hooks"    $  rr) __future__rr r(rr subprocessrrr/r configparserr ImportErrorrBrZ flake8.enginerr flake8.mainr rArHrrErcrjrortrrrr?r?r?r@s:       L   # $flake8-2.5.4/flake8/__pycache__/main.cpython-34.pyc00006440_j0000001073012641043677021526 0ustar ian770800000000000000 oV@s ddlZddlZddlZddlZddlmZmZddlmZej j dr}ej j dZ n0ej jejdpej j ddZ gZd d Zd d ZfdddZfdddZGdddejZdS)N) get_parserget_style_guide)option_normalizerwinz ~\.flake8ZXDG_CONFIG_HOMEz ~/.configflake8cCstdddt}|j}|jrAddlm}|n|j}t||}|dkr}t|dkndS)z.Parse options and run checks on Python source. parse_argvT config_filer) install_hookN)rDEFAULT_CONFIGoptionsr flake8.hooks check_files print_report SystemExit) flake8_styler r report exit_coder,/Users/ian7708/sandbox/flake8/flake8/main.pymains     rcCs{|j}|jr|jn|jr5|jn|jrw|jrgtjj t |jdn|j swdSndS)N r) r statisticsprint_statistics benchmarkprint_benchmark total_errorscountsysstderrwritestrZ exit_zero)rrr rrrr(s         rrcCs=t|jt}tdtd|d|}|j|S)aChecks 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 rignoremax_complexity)setunion EXTRA_IGNORErr input_file)pathr" complexityrrrr check_file7sr*cCsLt|jt}tdtd|d|}|jdd|jdS)a 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 rr"r#NlinesT)r$r%r&rr r' splitlines)coder"r)rrrr check_codeEsr.c@sReZdZdZdZgZddZddZddZd d Z d S) Flake8CommandzhThe :class:`Flake8Command` class is used by setuptools to perform checks on registered modules. z.Run flake8 on modules registered in setuptoolscCsti|_td}xW|jD]L}|jddd}|jdd}||j|s         flake8-2.5.4/flake8/__pycache__/reporter.cpython-34.pyc00006440_j0000001071012641043677022442 0ustar ian770800000000000000 oV @sddlZddlZddlZddlZyddlZWnek rZdZYnXddlZdddgZGdddejZ Gddde Z Gdddej e Z dS) Nmultiprocessing BaseQReport QueueReportcseZdZdZdZeejgZfddZ ddZ ddZ d d Z fd d Z fd dZddZddZddZS)rzBase Queue Report.Fcs|jdksttt|j|tjt|_|j|_ t j |_ t j |_ tjdkrttjd_ndS)Nrwin32__main__)jobsAssertionErrorsuperr__init__ collections defaultdictintcountersn_jobsrQueue task_queue result_queuesysplatform__file__modules)selfoptions) __class__0/Users/ian7708/sandbox/flake8/flake8/reporter.pyr $s zBaseQReport.__init__cCs!x|js|jqWdS)N)empty get_nowait)rqueuerrr_cleanup_queue1szBaseQReport._cleanup_queuecCsDx=t|jD],}|jjd|j|jjqWdS)NDONE)rangerrput update_staterget)rirrr _put_done5szBaseQReport._put_donecCsf|js5ddlm}m}|ddd|nx*t|jjdD]}|j|qKWdS)Nr)get_style_guideDEFAULT_CONFIG parse_argvT config_filer )_loadedZ flake8.mainr'r(iterrr$ input_file)rr'r(filenamerrr _process_main;s  zBaseQReport._process_maincsett|jd|j_x?t|jD].}tjd|j }d|_ |jq/WdS)NTtarget) r rstartrr+r!rrProcess process_maindaemon)rr%p)rrrr1Cs   zBaseQReport.startcsbz'y|jWntk r%YnXWd|j|j|j|jtt|jXdS)N)r&KeyboardInterruptrrrr rstop)r)rrrr7Ls  zBaseQReport.stopcCszcy|jWnNtk r%Yn=tk ra}z|j|jkrOnWYdd}~XnXWdtjjtjj|j j |j XdS)N) r/r6IOErrorerrnoignored_errorsrstdoutflushstderrrr" get_state)rZioerrrrrr3Ws   zBaseQReport.process_maincCs"i|jd6|jd6|jd6S)N total_errorsrmessages)r?rr@)rrrrr>gs  zBaseQReport.get_statecCs]|j|d7_x/|djD]\}}|j||7r#rr)rrrs       c@seZdZdZdZdS) FileQReportzFile Queue Report.TN)rFrGrHrIprint_filenamerrrrrLss rLc@s"eZdZdZddZdS)rzStandard Queue Report.cCsE|jjx.|jD]#\}}}}}t|ji|jd6|j|d6|dd6|d6|d6tjj|j r|t |j krd}n|j |d}t|j tjjtt jdd |d |d tjjn|jr|rtd |jtjjqqW|jS) zs       aflake8-2.5.4/flake8/__pycache__/util.cpython-34.pyc00006440_j0000000472112641043677021562 0ustar ian770800000000000000 oVG @sddlZyddlZejZWncek rddlZdejjkrzfej_eddej _nddZYnXGddde Z d d Z d d Z d dZddZddZdS)Ndecorator_listcCs|jS)N) decorators)sr,/Users/ian7708/sandbox/flake8/flake8/util.py srccs|js dSxz|jD]o}t||d}t|tjrI|Vqt|trx+|D] }t|tjr_|Vq_q_WqqWdS)z 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)_fieldsgetattr isinstanceastASTlist)nodenamefielditemrrriter_child_nodess  rc@s(eZdZdZfZddZdS) OrderedSetzList without duplicates.cCs ||kr|j|ndS)N)append)selfvaluerrradd$s zOrderedSet.addN)__name__ __module__ __qualname____doc__ __slots__rrrrrr s rcCs tjdkS)z#Determine if the system is Windows.nt)osrrrrr is_windows)srcCs d|kS)z+Determine if we're running checks on stdin.-r)pathsrrris_using_stdin.sr"cCs4|jo3|jo3|jjo3t|jdkS)N)verbosejobsisdigitint)optionsrrrwarn_when_using_jobs3s!r)cCstpt|jS)N)rr"r!) styleguiderrrforce_disable_jobs8sr+cCstt|jdkr!d}nt|jdkrBd }nt|trpd d |jd D}n|S)N1TTRUEONT0FFALSEOFFFcSs(g|]}|jr|jqSr)strip).0optrrr Cs z%option_normalizer..,)r,r-zTRUEzON)r0r1zFALSEzOFF)strupperr split)rrrroption_normalizer<s  r<)rr r ImportError_astClassDefrrproperty FunctionDefr rrr"r)r+r<rrrrs          flake8-2.5.4/flake8/_pyflakes.py00006440_j0000001077512646222541016300 0ustar ian770800000000000000# -*- coding: utf-8 -*- try: # The 'demandimport' breaks pyflakes and flake8._pyflakes from mercurial import demandimport except ImportError: pass else: demandimport.disable() import os import pep8 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__ def __init__(self, tree, filename): filename = pep8.normalize_paths(filename)[0] withDoctest = self.withDoctest included_by = [include for include in self.include_in_doctest if include != '' and filename.startswith(include)] if included_by: withDoctest = True for exclude in self.exclude_from_doctest: if exclude != '' and filename.startswith(exclude): withDoctest = False overlaped_by = [include for include in included_by if include.startswith(exclude)] if overlaped_by: withDoctest = True super(FlakesChecker, self).__init__(tree, filename, withDoctest=withDoctest) @classmethod def add_options(cls, parser): parser.add_option('--builtins', help="define more built-ins, comma separated") parser.add_option('--doctests', default=False, action='store_true', help="check syntax of the doctests") parser.add_option('--include-in-doctest', default='', dest='include_in_doctest', help='Run doctests only on these files', type='string') parser.add_option('--exclude-from-doctest', default='', dest='exclude_from_doctest', help='Skip these files when running doctests', type='string') parser.config_options.extend(['builtins', 'doctests', 'include-in-doctest', 'exclude-from-doctest']) @classmethod def parse_options(cls, options): if options.builtins: cls.builtIns = cls.builtIns.union(options.builtins.split(',')) cls.withDoctest = options.doctests included_files = [] for included_file in options.include_in_doctest.split(','): if included_file == '': continue if not included_file.startswith((os.sep, './', '~/')): included_files.append('./' + included_file) else: included_files.append(included_file) cls.include_in_doctest = pep8.normalize_paths(','.join(included_files)) excluded_files = [] for excluded_file in options.exclude_from_doctest.split(','): if excluded_file == '': continue if not excluded_file.startswith((os.sep, './', '~/')): excluded_files.append('./' + excluded_file) else: excluded_files.append(excluded_file) cls.exclude_from_doctest = pep8.normalize_paths( ','.join(excluded_files)) inc_exc = set(cls.include_in_doctest).intersection( set(cls.exclude_from_doctest)) if inc_exc: raise ValueError('"%s" was specified in both the ' 'include-in-doctest and exclude-from-doctest ' 'options. You are not allowed to specify it in ' 'both for doctesting.' % inc_exc) 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.5.4/flake8/_pyflakes.pyc00006440_j0000001132612641044042016425 0ustar ian770800000000000000 "AVc @syddklZWnej on XeiddkZddkZddkZddkZdZedei i fdYZ dS(i(t demandimportNcCstg}dD] }||id d dq~}xdttiiD]M\}}|dio0|io&d|i|d|if|_ qPqPWd 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(t_[1]tlinetcodestnametobj((s1/Users/ian7708/sandbox/flake8/flake8/_pyflakes.pytpatch_pyflakess" 0 t FlakesCheckercBsMeZdZdZeiZdZedZ edZ dZ RS(s=Subclass the Pyflakes checker to conform with the flake8 API.Rc Csti|d}|i}g}|iD].}|djo|i|o ||q*q*~}|o t}nx~|iD]s}|djo`|i|oPt}g}|D]!}|i|o ||qq~} | o t}qq|q|Wtt |i ||d|dS(Nitt withDoctest( tpep8tnormalize_pathsRtinclude_in_doctestt startswithtTruetexclude_from_doctesttFalsetsuperRt__init__( tselfttreetfilenameRR tincludet included_bytexcludet_[2]t overlaped_by((s1/Users/ian7708/sandbox/flake8/flake8/_pyflakes.pyR,s  1  $c Cs|iddd|iddtdddd|id dd d d dd dd|iddd d ddddd|iiddddgdS(Ns --builtinsthelps&define more built-ins, comma separateds --docteststdefaulttactiont store_truescheck syntax of the doctestss--include-in-doctestRtdestRs Run doctests only on these filesttypetstrings--exclude-from-doctestRs&Skip these files when running docteststbuiltinstdoctestssinclude-in-doctestsexclude-from-doctest(t add_optionRtconfig_optionstextend(tclstparser((s1/Users/ian7708/sandbox/flake8/flake8/_pyflakes.pyt add_options@s cCs|io%|ii|iid|_n|i|_g}xl|iidD]X}|djoqTn|iti ddfp|i d|qT|i |qTWt i di ||_g}xl|iidD]X}|djoqn|iti ddfp|i d|q|i |qWt i di ||_t|iit|i}|otd|ndS(Nt,Rs./s~/s"%s" was specified in both the include-in-doctest and exclude-from-doctest options. You are not allowed to specify it in both for doctesting.(R-tbuiltInstunionRR.RRRtostseptappendRRtjoinRtsett intersectiont ValueError(R2toptionstincluded_filest included_filetexcluded_filest excluded_filetinc_exc((s1/Users/ian7708/sandbox/flake8/flake8/_pyflakes.pyt parse_optionsRs6 %   ccsKxD|iD]9}t|dd}|i||i|i|ifVq WdS(Ntcoli(RtgetattrtlinenoR t message_argst __class__(RtmRF((s1/Users/ian7708/sandbox/flake8/flake8/_pyflakes.pytrunus ( t__name__t __module__t__doc__RRt __version__tversionRt classmethodR4RERL(((s1/Users/ian7708/sandbox/flake8/flake8/_pyflakes.pyR's  #( t mercurialRt ImportErrortdisableR8RRtpyflakes.checkerRtcheckertCheckerR(((s1/Users/ian7708/sandbox/flake8/flake8/_pyflakes.pyts      flake8-2.5.4/flake8/callbacks.py00006440_j0000000165712477326334016250 0ustar ian770800000000000000import atexit import sys def install_vcs_hook(option, option_str, value, parser): # For now, there's no way to affect a change in how pep8 processes # options. If no args are provided and there's no config file present, # it will error out because no input was provided. To get around this, # when we're using --install-hook, we'll say that there were arguments so # we can actually attempt to install the hook. # See: https://gitlab.com/pycqa/flake8/issues/2 and # https://github.com/jcrocholl/pep8/blob/4c5bf00cb613be617c7f48d3b2b82a1c7b895ac1/pep8.py#L1912 # for more context. parser.values.install_hook = True parser.rargs.append('.') def restore_stdout(old_stdout): sys.stdout.close() sys.stdout = old_stdout def redirect_stdout(option, option_str, value, parser): fd = open(value, 'w') old_stdout, sys.stdout = sys.stdout, fd atexit.register(restore_stdout, old_stdout) flake8-2.5.4/flake8/callbacks.pyc00006440_j0000000173112641044042016366 0ustar ian770800000000000000 ܬTc@s7ddkZddkZdZdZdZdS(iNcCs t|i_|iiddS(Nt.(tTruetvaluest install_hooktrargstappend(toptiont option_strtvaluetparser((s1/Users/ian7708/sandbox/flake8/flake8/callbacks.pytinstall_vcs_hooks cCstii|t_dS(N(tsyststdouttclose(t old_stdout((s1/Users/ian7708/sandbox/flake8/flake8/callbacks.pytrestore_stdouts cCs6t|d}ti|}t_tit|dS(Ntw(topenR R tatexittregisterR(RRRR tfdR((s1/Users/ian7708/sandbox/flake8/flake8/callbacks.pytredirect_stdouts(RR R RR(((s1/Users/ian7708/sandbox/flake8/flake8/callbacks.pyts   flake8-2.5.4/flake8/compat.py00006440_j0000000053312477326610015601 0ustar ian770800000000000000# -*- coding: utf-8 -*- """Compatibility shims for Flake8.""" import os.path import sys def relpath(path, start='.'): """Wallpaper over the differences between 2.6 and newer versions.""" if sys.version_info < (2, 7) and path.startswith(start): return path[len(start):] else: return os.path.relpath(path, start=start) flake8-2.5.4/flake8/compat.pyc00006440_j0000000120712641044042015730 0ustar ian770800000000000000 Tc@s.dZddkZddkZddZdS(sCompatibility shims for Flake8.iNt.cCsItidjo|i|o|t|Stii|d|SdS(s>Wallpaper over the differences between 2.6 and newer versions.iitstartN(ii(tsyst version_infot startswithtlentostpathtrelpath(RR((s./Users/ian7708/sandbox/flake8/flake8/compat.pyRs (t__doc__tos.pathRRR(((s./Users/ian7708/sandbox/flake8/flake8/compat.pyts  flake8-2.5.4/flake8/engine.py00006440_j0000002635712657145152015577 0ustar ian770800000000000000# -*- coding: utf-8 -*- import errno import io import platform import re import sys import warnings import pep8 from flake8 import __version__ from flake8 import callbacks from flake8.reporter import (multiprocessing, BaseQReport, FileQReport, QueueReport) from flake8 import util _flake8_noqa = re.compile(r'\s*# flake8[:=]\s*noqa', re.I).search EXTRA_EXCLUDE = ['.tox', '.eggs', '*.egg'] pep8.PROJECT_CONFIG += ('.flake8',) def _load_entry_point(entry_point, verify_requirements): """Based on the version of setuptools load an entry-point correctly. setuptools 11.3 deprecated `require=False` in the call to EntryPoint.load. To load entry points correctly after that without requiring all dependencies be present, the proper way is to call EntryPoint.resolve. This function will provide backwards compatibility for older versions of setuptools while also ensuring we do the right thing for the future. """ if hasattr(entry_point, 'resolve') and hasattr(entry_point, 'require'): if verify_requirements: entry_point.require() plugin = entry_point.resolve() else: plugin = entry_point.load(require=verify_requirements) return plugin def _register_extensions(): """Register all the extensions.""" extensions = util.OrderedSet() extensions.add(('pep8', pep8.__version__)) parser_hooks = [] options_hooks = [] ignored_hooks = [] try: from pkg_resources import iter_entry_points except ImportError: pass else: for entry in iter_entry_points('flake8.extension'): # Do not verify that the requirements versions are valid checker = _load_entry_point(entry, verify_requirements=False) 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) if getattr(checker, 'off_by_default', False) is True: ignored_hooks.append(entry.name) return extensions, parser_hooks, options_hooks, ignored_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, ignored) = _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 if multiprocessing: parser.config_options.append('jobs') parser.add_option('-j', '--jobs', type='string', default='auto', help="number of jobs to run simultaneously, " "or 'auto'. This is ignored on Windows.") 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) # See comment above regarding why this has to be a callback. parser.add_option('--install-hook', default=False, dest='install_hook', help='Install the appropriate hook for this ' 'repository.', action='callback', callback=callbacks.install_vcs_hook) parser.add_option('--output-file', default=None, help='Redirect report to a file.', type='string', nargs=1, action='callback', callback=callbacks.redirect_stdout) parser.add_option('--enable-extensions', default='', dest='enable_extensions', help='Enable plugins and extensions that are disabled ' 'by default', type='string') parser.config_options.extend(['output-file', 'enable-extensions']) parser.ignored_extensions = ignored return parser, options_hooks class NoQAStyleGuide(pep8.StyleGuide): 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" comments to ignore the entire file? if any(_flake8_noqa(line) for line in fchecker.lines): return 0 return fchecker.check_all(expected=expected, line_offset=line_offset) class StyleGuide(object): """A wrapper StyleGuide object for Flake8 usage. This allows for OSErrors to be caught in the styleguide and special logic to be used to handle those errors. """ # Reasoning for error numbers is in-line below serial_retry_errors = set([ # ENOSPC: Added by sigmavirus24 # > On some operating systems (OSX), multiprocessing may cause an # > ENOSPC error while trying to trying to create a Semaphore. # > In those cases, we should replace the customized Queue Report # > class with pep8's StandardReport class to ensure users don't run # > into this problem. # > (See also: https://gitlab.com/pycqa/flake8/issues/74) errno.ENOSPC, # NOTE(sigmavirus24): When adding to this list, include the reasoning # on the lines before the error code and always append your error # code. Further, please always add a trailing `,` to reduce the visual # noise in diffs. ]) def __init__(self, **kwargs): # This allows us to inject a mocked StyleGuide in the tests. self._styleguide = kwargs.pop('styleguide', NoQAStyleGuide(**kwargs)) @property def options(self): return self._styleguide.options @property def paths(self): return self._styleguide.paths def _retry_serial(self, func, *args, **kwargs): """This will retry the passed function in serial if necessary. In the event that we encounter an OSError with an errno in :attr:`serial_retry_errors`, this function will retry this function using pep8's default Report class which operates in serial. """ try: return func(*args, **kwargs) except OSError as oserr: if oserr.errno in self.serial_retry_errors: self.init_report(pep8.StandardReport) else: raise return func(*args, **kwargs) def check_files(self, paths=None): return self._retry_serial(self._styleguide.check_files, paths=paths) def excluded(self, filename, parent=None): return self._styleguide.excluded(filename, parent=parent) def init_report(self, reporter=None): return self._styleguide.init_report(reporter) def input_file(self, filename, lines=None, expected=None, line_offset=0): return self._retry_serial( self._styleguide.input_file, filename=filename, lines=lines, expected=expected, line_offset=line_offset, ) def _parse_multi_options(options, split_token=','): r"""Split and strip and discard empties. Turns the following: A, B, into ["A", "B"]. Credit: Kristian Glass as contributed to pep8 """ if options: return [o.strip() for o in options.split(split_token) if o.strip()] else: return options def _disable_extensions(parser, options): ignored_extensions = set(getattr(parser, 'ignored_extensions', [])) enabled = set(_parse_multi_options(options.enable_extensions)) # Remove any of the selected extensions from the extensions ignored by # default. ignored_extensions -= enabled # Whatever is left afterwards should be unioned with options.ignore and # options.ignore should be updated with that. options.ignore = tuple(ignored_extensions.union(options.ignore)) 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 _disable_extensions(kwargs['parser'], options) if options.exclude and not isinstance(options.exclude, list): options.exclude = pep8.normalize_paths(options.exclude) elif not options.exclude: options.exclude = [] # Add patterns in EXTRA_EXCLUDE to the list of excluded patterns options.exclude.extend(pep8.normalize_paths(EXTRA_EXCLUDE)) for options_hook in options_hooks: options_hook(options) if util.warn_when_using_jobs(options): if not multiprocessing: warnings.warn("The multiprocessing module is not available. " "Ignoring --jobs arguments.") if util.is_windows(): warnings.warn("The --jobs option is not available on Windows. " "Ignoring --jobs arguments.") if util.is_using_stdin(styleguide.paths): warnings.warn("The --jobs option is not compatible with supplying " "input using - . Ignoring --jobs arguments.") if options.diff: warnings.warn("The --diff option was specified with --jobs but " "they are not compatible. Ignoring --jobs arguments." ) if options.diff: options.jobs = None force_disable_jobs = util.force_disable_jobs(styleguide) if multiprocessing and options.jobs and not force_disable_jobs: if options.jobs.isdigit(): n_jobs = int(options.jobs) else: try: n_jobs = multiprocessing.cpu_count() except NotImplementedError: n_jobs = 1 if n_jobs > 1: options.jobs = n_jobs reporter = QueueReport if options.quiet: reporter = BaseQReport if options.quiet == 1: reporter = FileQReport report = styleguide.init_report(reporter) report.input_file = styleguide.input_file styleguide.runner = report.task_queue.put 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()) def make_stdin_get_value(original): def stdin_get_value(): if not hasattr(stdin_get_value, 'cached_stdin'): value = original() if sys.version_info < (3, 0): stdin = io.BytesIO(value) else: stdin = io.StringIO(value) stdin_get_value.cached_stdin = stdin else: stdin = stdin_get_value.cached_stdin return stdin.getvalue() return stdin_get_value pep8.stdin_get_value = make_stdin_get_value(pep8.stdin_get_value) flake8-2.5.4/flake8/engine.pyc00006440_j0000002601312641044042015714 0ustar ian770800000000000000 "AVc@slddkZddkZddkZddkZddkZddkZddkZddklZddkl Z ddk l Z l Z l Z lZddklZeideiiZddd gZeid7_d Zd Zd ZdeifdYZdefdYZddZdZdZdZdZ e ei!e_!dS(iN(t __version__(t callbacks(tmultiprocessingt BaseQReportt FileQReportt QueueReport(tutils\s*# flake8[:=]\s*noqas.toxs.eggss*.eggs.flake8cCs[t|do5t|do%|o|in|i}n|id|}|S(sBased on the version of setuptools load an entry-point correctly. setuptools 11.3 deprecated `require=False` in the call to EntryPoint.load. To load entry points correctly after that without requiring all dependencies be present, the proper way is to call EntryPoint.resolve. This function will provide backwards compatibility for older versions of setuptools while also ensuring we do the right thing for the future. tresolvetrequire(thasattrRRtload(t entry_pointtverify_requirementstplugin((s./Users/ian7708/sandbox/flake8/flake8/engine.pyt_load_entry_points c Cs>ti}|idtifg}g}g}yddkl}Wntj onXx|dD]}t|dt }ti |d|i g|i|i |i ft |do|i|int |do|i|int|d t tjo|i|i qkqkW||||fS( sRegister all the extensions.tpep8i(titer_entry_pointssflake8.extensionR tcodest add_optionst parse_optionstoff_by_default(Rt OrderedSettaddRRt pkg_resourcesRt ImportErrorRtFalsetregister_checktnametversionR tappendRRtgetattrtTrue(t extensionst parser_hookst options_hookst ignored_hooksRtentrytchecker((s./Users/ian7708/sandbox/flake8/flake8/engine.pyt_register_extensions,s*  c Cst\}}}}did|D}t}tiddt||f}x5d"D]-}y|i|Wq]tj oq]Xq]Wto6|i i d|i d d d d d dddn|i dddddx|D]}||qW|i dd t dddddddt i|i dd d#ddd d dddddt i|i dd ddd dd!d d ||_||fS($sThis returns an instance of optparse.OptionParser with all the extensions registered and options set. This wraps ``pep8.get_parser``. s, cssx|]}d|VqWdS(s%s: %sN((t.0text((s./Users/ian7708/sandbox/flake8/flake8/engine.pys Ks tflake8s %s (%s) %ss--repeats --testsuites --doctesttjobss-js--jobsttypetstringtdefaulttautothelpsLnumber of jobs to run simultaneously, or 'auto'. This is ignored on Windows.s --exit-zerotactiont store_trues)exit with code 0 even if there are errorss--install-hooktdestt install_hooks1Install the appropriate hook for this repository.tcallbacks --output-filesRedirect report to a file.tnargsis--enable-extensionsttenabled_extensionss:Enable plugins and extensions that are disabled by default(s--repeats --testsuites --doctestN(R&tjointget_python_versionRt get_parserRt remove_optiont ValueErrorRtconfig_optionsRt add_optionRRtinstall_vcs_hooktNonetredirect_stdouttignored_extensions( R R!R"tignoredtdetailstpython_versiontparsertoptt parser_hook((s./Users/ian7708/sandbox/flake8/flake8/engine.pyR:FsD       tNoQAStyleGuidecBseZddddZRS(icCsm|iio d|GHn|i|d|d|i}td|iDodS|id|d|S(s'Run all checks on a Python source file.s checking %stlinestoptionscssx|]}t|VqWdS(N(t _flake8_noqa(R'tline((s./Users/ian7708/sandbox/flake8/flake8/engine.pys {s itexpectedt line_offset(RKtverboset checker_classtanyRJt check_all(tselftfilenameRJRNROtfchecker((s./Users/ian7708/sandbox/flake8/flake8/engine.pyt input_filets  N(t__name__t __module__R@RW(((s./Users/ian7708/sandbox/flake8/flake8/engine.pyRIrst StyleGuidecBseZdZeeigZdZedZ edZ dZ d dZ d dZd dZd d dd ZRS( sA wrapper StyleGuide object for Flake8 usage. This allows for OSErrors to be caught in the styleguide and special logic to be used to handle those errors. cKs|idt||_dS(Nt styleguide(tpopRIt _styleguide(RTtkwargs((s./Users/ian7708/sandbox/flake8/flake8/engine.pyt__init__scCs |iiS(N(R]RK(RT((s./Users/ian7708/sandbox/flake8/flake8/engine.pyRKscCs |iiS(N(R]tpaths(RT((s./Users/ian7708/sandbox/flake8/flake8/engine.pyR`scOsay|||SWnItj o=}|i|ijo|itin|||SXdS(sThis will retry the passed function in serial if necessary. In the event that we encounter an OSError with an errno in :attr:`serial_retry_errors`, this function will retry this function using pep8's default Report class which operates in serial. N(tOSErrorterrnotserial_retry_errorst init_reportRtStandardReport(RTtfunctargsR^toserr((s./Users/ian7708/sandbox/flake8/flake8/engine.pyt _retry_serialscCs|i|iid|S(NR`(RiR]t check_files(RTR`((s./Users/ian7708/sandbox/flake8/flake8/engine.pyRjscCs|ii|d|S(Ntparent(R]texcluded(RTRURk((s./Users/ian7708/sandbox/flake8/flake8/engine.pyRlscCs|ii|S(N(R]Rd(RTtreporter((s./Users/ian7708/sandbox/flake8/flake8/engine.pyRdsic Cs+|i|iid|d|d|d|S(NRURJRNRO(RiR]RW(RTRURJRNRO((s./Users/ian7708/sandbox/flake8/flake8/engine.pyRWs  N(RXRYt__doc__tsetRbtENOSPCRcR_tpropertyRKR`RiR@RjRlRdRW(((s./Users/ian7708/sandbox/flake8/flake8/engine.pyRZs     t,cCsO|o@g}|i|D]$}|io||iqq~S|SdS(sSplit and strip and discard empties. Turns the following: A, B, into ["A", "B"]. Credit: Kristian Glass as contributed to pep8 N(tsplittstrip(RKt split_tokent_[1]to((s./Users/ian7708/sandbox/flake8/flake8/engine.pyt_parse_multi_optionss @cCsVtt|dg}tt|i}||8}t|i|i|_dS(NRB(RoRRxR7ttupletuniontignore(RFRKRBtenabled((s./Users/ian7708/sandbox/flake8/flake8/engine.pyt_disable_extensionss c KsRt\|d<}t|}|i}t|d||io-t|it oti|i|_n|ip g|_n|ii tit x|D]}||qWt i |oyt ptidnt iotidnt i|iotidn|iotidqDn|io d|_nt i|}t o|io| o|iiot|i}n-yt i}Wntj o d}nX|djok||_t}|io$t}|idjo t}qn|i|}|i |_ |i!i"|_#qNn|S(saParse the options and configure the checker. This returns a sub-class of ``pep8.StyleGuide``.RFsGThe multiprocessing module is not available. Ignoring --jobs arguments.sIThe --jobs option is not available on Windows. Ignoring --jobs arguments.s]The --jobs option is not compatible with supplying input using - . Ignoring --jobs arguments.scThe --diff option was specified with --jobs but they are not compatible. Ignoring --jobs arguments.iN($R:RZRKR}texcludet isinstancetlistRtnormalize_pathstextendt EXTRA_EXCLUDERtwarn_when_using_jobsRtwarningstwarnt is_windowstis_using_stdinR`tdiffR@R*tforce_disable_jobstisdigittintt cpu_counttNotImplementedErrorRtquietRRRdRWt task_queuetputtrunner( R^R"R[RKt options_hookRtn_jobsRmtreport((s./Users/ian7708/sandbox/flake8/flake8/engine.pytget_style_guidesT             cCsMytid}Wntj o d}nXd|titifS(Nt R6s %s%s on %s(tplatformtpython_implementationtAttributeErrorREtsystem(timpl((s./Users/ian7708/sandbox/flake8/flake8/engine.pyR9"s  csfdS(NcsktdpH}tidjoti|}nti|}|_n i}|iS(Nt cached_stdinii(ii(R tsyst version_infotiotBytesIOtStringIORtgetvalue(tvaluetstdin(toriginaltstdin_get_value(s./Users/ian7708/sandbox/flake8/flake8/engine.pyR,s   ((R((RRs./Users/ian7708/sandbox/flake8/flake8/engine.pytmake_stdin_get_value+s (s.flake8("RbRRtreRRRR)RRtflake8.reporterRRRRRtcompiletItsearchRLRtPROJECT_CONFIGRR&R:RZRItobjectRxR}RR9RR(((s./Users/ian7708/sandbox/flake8/flake8/engine.pyts0       "   ,F  = flake8-2.5.4/flake8/hooks.py00006440_j0000002346612641006650015443 0ustar ian770800000000000000# -*- coding: utf-8 -*- from __future__ import with_statement import os import pep8 import sys import stat from subprocess import Popen, PIPE import shutil import tempfile try: from configparser import ConfigParser except ImportError: # Python 2 from ConfigParser import ConfigParser from flake8 import compat 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 tmpdir = tempfile.mkdtemp() flake8_style = get_style_guide(config_file=DEFAULT_CONFIG, paths=['.'], **options) filepatterns = flake8_style.options.filename # Copy staged versions to temporary directory 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 = compat.relpath(dirname, start=prefix) dirname = os.path.join(tmpdir, dirname) if not os.path.isdir(dirname): os.makedirs(dirname) # check_files() only does this check if passed a dir; so we do it if ((pep8.filename_match(file_, filepatterns) and not flake8_style.excluded(file_))): filename = os.path.join(dirname, filename) files_to_check.append(filename) # write staged version of file to temporary directory with open(filename, "wb") as fh: fh.write(out) # 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=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(config_file=config, paths=['.'], **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 decode: if hasattr(stdout, 'decode'): stdout = stdout.decode('utf-8') if hasattr(stderr, 'decode'): stderr = stderr.decode('utf-8') 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(): try: _, git_dir, _ = run('git rev-parse --git-dir') except OSError: pass else: 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') try: _, hg_dir, _ = run('hg root') except OSError: pass else: if hg_dir and os.path.isdir(hg_dir[0]): return os.path.join(hg_dir[0], '.hg', 'hgrc') return '' def get_git_config(option, opt_type='', convert_type=True): # type can be --bool, --int or an empty string _, git_cfg_value, _ = run('git config --get %s %s' % (opt_type, option), raw_output=True) git_cfg_value = git_cfg_value.strip() if not convert_type: return git_cfg_value if opt_type == '--bool': git_cfg_value = git_cfg_value.lower() == 'true' elif git_cfg_value and opt_type == '--int': git_cfg_value = int(git_cfg_value) return git_cfg_value _params = { 'FLAKE8_COMPLEXITY': '--int', 'FLAKE8_STRICT': '--bool', 'FLAKE8_IGNORE': '', 'FLAKE8_LAZY': '--bool', } def get_git_param(option, default=''): global _params opt_type = _params[option] param_value = get_git_config(option.lower().replace('_', '.'), opt_type=opt_type, convert_type=False) if param_value == '': param_value = os.environ.get(option, default) if opt_type == '--bool' and not isinstance(param_value, bool): param_value = param_value.lower() == 'true' elif param_value and opt_type == '--int': param_value = int(param_value) return param_value git_hook_file = """#!/usr/bin/env python import sys from flake8.hooks import git_hook, get_git_param # `get_git_param` will retrieve configuration from your local git config and # then fall back to using the environment variables that the hook has always # supported. # For example, to set the complexity, you'll need to do: # git config flake8.complexity 10 COMPLEXITY = get_git_param('FLAKE8_COMPLEXITY', 10) STRICT = get_git_param('FLAKE8_STRICT', False) IGNORE = get_git_param('FLAKE8_IGNORE', None) LAZY = get_git_param('FLAKE8_LAZY', False) if __name__ == '__main__': sys.exit(git_hook( complexity=COMPLEXITY, strict=STRICT, ignore=IGNORE, lazy=LAZY, )) """ def _install_hg_hook(path): getenv = os.environ.get 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(getenv('FLAKE8_COMPLEXITY', 10))) if not c.has_option('flake8', 'strict'): c.set('flake8', 'strict', getenv('FLAKE8_STRICT', False)) if not c.has_option('flake8', 'ignore'): c.set('flake8', 'ignore', getenv('FLAKE8_IGNORE', '')) if not c.has_option('flake8', 'lazy'): c.set('flake8', 'lazy', getenv('FLAKE8_LAZY', False)) with open(path, 'w') as fd: c.write(fd) 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.\n') p.print_help() sys.exit(1) status = 0 if 'git' in vcs: if os.path.exists(vcs): sys.exit('Error: hook already exists (%s)' % 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.5.4/flake8/hooks.pyc00006440_j0000002177012641044042015577 0ustar ian770800000000000000 Vc@svddklZddkZddkZddkZddkZddklZlZddk Z ddk Z yddk l Z Wn#e j oddk l Z nXddklZddklZlZddklZdededZd Zeed Zd Zd Zd edZhdd6dd6d d6dd6ad dZdZ dZ!dZ"dS(i(twith_statementN(tPopentPIPE(t ConfigParser(tcompat(t get_parsertget_style_guide(tDEFAULT_CONFIGc CsPd}|o|idd}nt|do|id}nt|\}}}h}|o||d} d | } t| d t dt \}}}t i it i i| \}}t i i||g}ti|d|}t i i||}t i i|pt i|nti| | op| i|  o_t i i||}| i|t|dii}z|~}|i|WdQXqqW| i| }Wdti|dt X|o|i SdS(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 --diff-filter=ACMRTUXB HEADs --cached ttsplitt,tignoreitmax_complexityt config_filetpathst.s git show :%st raw_outputtdecodetstarttwbNt ignore_errorsi(!treplacethasattrR trunttempfiletmkdtempRRtoptionstfilenametTruetFalsetostpathtabspatht commonprefixRtrelpathtjointisdirtmakedirstpep8tfilename_matchtexcludedtappendtopent__exit__t __enter__twritet check_filestshutiltrmtreet total_errors(t complexitytstrictR tlazytgitcmdt_tfiles_modifiedRttmpdirt flake8_stylet filepatternstfiles_to_checktfile_tgitcmd_getstagedtouttdirnameRtprefixt_[1]tfhtreport((s-/Users/ian7708/sandbox/flake8/flake8/hooks.pytgit_hooksL      !$ &c Ks|idddd}|idddt}|idddd }|idddt}t||}h}|o||dn|i ||i do |Vq>q>Wq'WdS(Ntnodes.py( tsettrangetlentfilesRRR#troottexiststaddtendswith(RLRMtseentrevR<((s-/Users/ian7708/sandbox/flake8/flake8/hooks.pyRJs ! c Csytd\}}}Wntj onX|o|tii|doetiitii|ddp$titii|ddntii|dddSytd\}}}Wntj on;X|o2tii|dotii|dddSdS( Nsgit rev-parse --git-dirithookss pre-commitshg roots.hgthgrcR(RtOSErrorRRR$R#tmkdir(R6tgit_dirthg_dir((s-/Users/ian7708/sandbox/flake8/flake8/hooks.pytfind_vcss&$RcCstd||fdt\}}}|i}|p|S|djo|idj}n%|o|djot|}n|S(Nsgit config --get %s %sRs--boolttrues--int(RRRStlowertint(toptiontopt_typet convert_typeR6t git_cfg_value((s-/Users/ian7708/sandbox/flake8/flake8/hooks.pytget_git_configs  s--inttFLAKE8_COMPLEXITYs--boolt FLAKE8_STRICTt FLAKE8_IGNOREt FLAKE8_LAZYcCst|}t|iiddd|dt}|djotii||}n|djo't|t  o|idj}n%|o|djot |}n|S( NR6RRoRpRs--boolRks--int( t_paramsRrRlRRRtenvirontgett isinstancetboolRm(RnRFRot param_value((s-/Users/ian7708/sandbox/flake8/flake8/hooks.pyt get_git_params  s#!/usr/bin/env python import sys from flake8.hooks import git_hook, get_git_param # `get_git_param` will retrieve configuration from your local git config and # then fall back to using the environment variables that the hook has always # supported. # For example, to set the complexity, you'll need to do: # git config flake8.complexity 10 COMPLEXITY = get_git_param('FLAKE8_COMPLEXITY', 10) STRICT = get_git_param('FLAKE8_STRICT', False) IGNORE = get_git_param('FLAKE8_IGNORE', None) LAZY = get_git_param('FLAKE8_LAZY', False) if __name__ == '__main__': sys.exit(git_hook( complexity=COMPLEXITY, strict=STRICT, ignore=IGNORE, lazy=LAZY, )) cCstii}tii|pt|dint}|it|d|i dp|i dn|i ddp|i dddn|i ddp|i dddn|i dp|i dn|i ddp&|i ddt |d d n|i dd p |i dd |d tn|i dd p |i dd |ddn|i ddp |i dd|dtnt|dii}z|~}|i|WdQXdS(NtwtrRdtcommitspython:flake8.hooks.hg_hooktqrefreshRER2Rsi R3RtR RuRR4Rv(RRxRyRtisfileR*tcloseRtreadfpt has_sectiont add_sectiont has_optionRZtstrRR+R,R-(RtgetenvtcRAtfd((s-/Users/ian7708/sandbox/flake8/flake8/hooks.pyt_install_hg_hooks.  &   &cCst}|p8td}tiid|itidnd}d|jotii |otid|nt |di i }z|~}|it WdQXti|titiBtiBn"d|jot|nd}ti|dS(NisfError: could not find either a git or mercurial directory. Please re-run this in a proper repository. itgitsError: hook already exists (%s)R~thg(RjRtsysRPR-t print_helptexitRRR_R*R+R,t git_hook_filetchmodtstattS_IRWXUtS_IRGRPtS_IROTHR(tvcsRVtstatusRAR((s-/Users/ian7708/sandbox/flake8/flake8/hooks.pyt install_hooks"    &% (#t __future__RRR&RRt subprocessRRR/Rt configparserRt ImportErrorRERt flake8.engineRRt flake8.mainRRRIRDRNRRRJRjRrRwR}RRR(((s-/Users/ian7708/sandbox/flake8/flake8/hooks.pyts:      L    # $flake8-2.5.4/flake8/main.py00006440_j0000001122412633612251015232 0ustar ian770800000000000000# -*- coding: utf-8 -*- import os import re import sys import setuptools from flake8.engine import get_parser, get_style_guide from flake8.util import option_normalizer 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 = [] 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) if exit_code > 0: 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 value = option_normalizer(value) # Check if there's any values that need to be fixed. if option_name == "include" and isinstance(value, str): value = re.findall('[^,;\s]+', 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 # Don't miss the setup.py file itself yield "setup.py" def run(self): # Prepare paths = list(self.distribution_files()) flake8_style = get_style_guide(config_file=DEFAULT_CONFIG, paths=paths, **self.options_dict) # Run the checkers report = flake8_style.check_files() exit_code = print_report(report, flake8_style) if exit_code > 0: raise SystemExit(exit_code > 0) flake8-2.5.4/flake8/main.pyc00006440_j0000001215512641044042015375 0ustar ian770800000000000000 oVc @sddkZddkZddkZddkZddklZlZddklZei i doei i dZ n2ei ieidpei i ddZ gZd Zd Zddd Zddd Zd eifdYZdS(iN(t get_parsertget_style_guide(toption_normalizertwins ~\.flake8tXDG_CONFIG_HOMEs ~/.configtflake8cCstdtdt}|i}|ioddkl}|n|i}t||}|djot|djndS(s.Parse options and run checks on Python source.t parse_argvt config_filei(t install_hookiN( RtTruetDEFAULT_CONFIGtoptionsRt flake8.hookst check_filest print_reportt SystemExit(t flake8_styleR Rtreportt exit_code((s,/Users/ian7708/sandbox/flake8/flake8/main.pytmains     cCs|i}|io|in|io|in|io>|io!tii t |idn|i pdSndS(Ns ii( R t statisticstprint_statisticst benchmarktprint_benchmarkt total_errorstcounttsyststderrtwritetstrt exit_zero(RRR ((s,/Users/ian7708/sandbox/flake8/flake8/main.pyR(s     !  cCs=t|it}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(tsettuniont EXTRA_IGNORERR t input_file(tpathRt complexityR((s,/Users/ian7708/sandbox/flake8/flake8/main.pyt check_file7scCsLt|it}tdtd|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 RRR tlinesN( R!R"R#RR R$tNonet splitlinesR (tcodeRR&R((s,/Users/ian7708/sandbox/flake8/flake8/main.pyt check_codeEst Flake8CommandcBs>eZdZdZgZdZdZdZdZRS(shThe :class:`Flake8Command` class is used by setuptools to perform checks on registered modules. s.Run flake8 on modules registered in setuptoolscCsnh|_td}xQ|iD]F}|idd}|idd}||i|R RR(R5RSRRR((s,/Users/ian7708/sandbox/flake8/flake8/main.pytruns    ( t__name__t __module__t__doc__t descriptiont user_optionsR:RERRRU(((s,/Users/ian7708/sandbox/flake8/flake8/main.pyR-Rs  (((RKRBRt setuptoolst flake8.engineRRt flake8.utilRtplatformt startswithR%t expanduserR tjointgetenvR#RRR'R,tCommandR-(((s,/Users/ian7708/sandbox/flake8/flake8/main.pyts         flake8-2.5.4/flake8/reporter.py00006440_j0000001222112633612251016146 0ustar ian770800000000000000# -*- coding: utf-8 -*- # Adapted from a contribution of Johan Dahlin import collections import errno import re import sys try: import multiprocessing except ImportError: # Python 2.5 multiprocessing = None import pep8 __all__ = ['multiprocessing', 'BaseQReport', 'QueueReport'] class BaseQReport(pep8.BaseReport): """Base Queue Report.""" _loaded = False # Windows support # Reasoning for ignored error numbers is in-line below ignored_errors = set([ # EPIPE: Added by sigmavirus24 # > If output during processing is piped to something that may close # > its own stdin before we've finished printing results, we need to # > catch a Broken pipe error and continue on. # > (See also: https://gitlab.com/pycqa/flake8/issues/69) errno.EPIPE, # NOTE(sigmavirus24): When adding to this list, include the reasoning # on the lines before the error code and always append your error # code. Further, please always add a trailing `,` to reduce the visual # noise in diffs. ]) def __init__(self, options): assert options.jobs > 0 super(BaseQReport, self).__init__(options) self.counters = collections.defaultdict(int) self.n_jobs = options.jobs # init queues self.task_queue = multiprocessing.Queue() self.result_queue = multiprocessing.Queue() if sys.platform == 'win32': # Work around http://bugs.python.org/issue10845 sys.modules['__main__'].__file__ = __file__ def _cleanup_queue(self, queue): while not queue.empty(): queue.get_nowait() def _put_done(self): # collect queues for i in range(self.n_jobs): self.task_queue.put('DONE') self.update_state(self.result_queue.get()) def _process_main(self): if not self._loaded: # Windows needs to parse again the configuration from flake8.main import get_style_guide, DEFAULT_CONFIG get_style_guide(parse_argv=True, config_file=DEFAULT_CONFIG) for filename in iter(self.task_queue.get, 'DONE'): self.input_file(filename) def start(self): super(BaseQReport, self).start() self.__class__._loaded = True # spawn processes for i in range(self.n_jobs): p = multiprocessing.Process(target=self.process_main) p.daemon = True p.start() def stop(self): try: self._put_done() except KeyboardInterrupt: pass finally: # cleanup queues to unlock threads self._cleanup_queue(self.result_queue) self._cleanup_queue(self.task_queue) super(BaseQReport, self).stop() def process_main(self): try: self._process_main() except KeyboardInterrupt: pass except IOError as ioerr: # If we happen across an IOError that we aren't certain can/should # be ignored, we should re-raise the exception. if ioerr.errno not in self.ignored_errors: raise finally: # ensure all output is flushed before main process continues sys.stdout.flush() sys.stderr.flush() self.result_queue.put(self.get_state()) def get_state(self): return {'total_errors': self.total_errors, 'counters': self.counters, 'messages': self.messages} def update_state(self, state): self.total_errors += state['total_errors'] for key, value in state['counters'].items(): self.counters[key] += value self.messages.update(state['messages']) class FileQReport(BaseQReport): """File Queue Report.""" print_filename = True class QueueReport(pep8.StandardReport, BaseQReport): """Standard Queue Report.""" def get_file_results(self): """Print the result and return the overall count for this file.""" self._deferred_print.sort() for line_number, offset, code, text, doc in self._deferred_print: print(self._fmt % { 'path': self.filename, 'row': self.line_offset + line_number, 'col': offset + 1, 'code': code, 'text': text, }) # stdout is block buffered when not stdout.isatty(). # line can be broken where buffer boundary since other processes # write to same file. # flush() after print() to avoid buffer boundary. # Typical buffer size is 8192. line written safely when # len(line) < 8192. sys.stdout.flush() if self._show_source: if line_number > len(self.lines): line = '' else: line = self.lines[line_number - 1] print(line.rstrip()) sys.stdout.flush() print(re.sub(r'\S', ' ', line[:offset]) + '^') sys.stdout.flush() if self._show_pep8 and doc: print(' ' + doc.strip()) sys.stdout.flush() return self.file_errors flake8-2.5.4/flake8/reporter.pyc00006440_j0000001216512641044042016314 0ustar ian770800000000000000 oVc @sddkZddkZddkZddkZyddkZWnej o dZnXddkZdddgZdei fdYZ de fdYZ dei e fdYZ dS( iNtmultiprocessingt BaseQReportt QueueReportcBsweZdZeZeeigZdZ dZ dZ dZ dZ dZdZdZd ZRS( sBase Queue Report.cCs|idjpttt|i|tit|_|i|_ t i |_ t i |_ tidjottid_ndS(Nitwin32t__main__(tjobstAssertionErrortsuperRt__init__t collectionst defaultdicttinttcounterstn_jobsRtQueuet task_queuet result_queuetsystplatformt__file__tmodules(tselftoptions((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyR$s cCs#x|ip|iqWdS(N(temptyt get_nowait(Rtqueue((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyt_cleanup_queue1s cCsDx=t|iD],}|iid|i|iiqWdS(NtDONE(trangeR Rtputt update_stateRtget(Rti((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyt _put_done5scCsh|ip-ddkl}l}|dtd|nx*t|iidD]}|i|qMWdS(Ni(tget_style_guidetDEFAULT_CONFIGt parse_argvt config_fileR( t_loadedt flake8.mainR"R#tTruetiterRRt input_file(RR"R#tfilename((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyt _process_main;s  cCsett|it|i_x?t|iD].}ti d|i }t|_ |iq/WdS(Nttarget( RRtstartR(t __class__R&RR RtProcesst process_maintdaemon(RR tp((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyR.Cs  c Cscz(y|iWntj onXWd|i|i|i|itt|iXdS(N(R!tKeyboardInterruptRRRRRtstop(R((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyR5Ls c CszVy|iWnAtj on0tj o#}|i|ijoqUnXWdtiitii|i i |i XdS(N( R,R4tIOErrorterrnotignored_errorsRtstdouttflushtstderrRRt get_state(Rtioerr((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyR1Ws  cCs"h|id6|id6|id6S(Nt total_errorsR tmessages(R>R R?(R((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyR<gs  cCs_|i|d7_x1|diD]\}}|i|c|7R R?(R>titemsR R?tupdate(Rtstatetkeytvalue((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyRls  (t__name__t __module__t__doc__tFalseR&tsetR7tEPIPER8RRR!R,R.R5R1R<R(((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyRs     t FileQReportcBseZdZeZRS(sFile Queue Report.(RERFRGR(tprint_filename(((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyRKsscBseZdZdZRS(sStandard Queue Report.cCs2|iix|iD]\}}}}}|ih|id6|i|d6|dd6|d6|d6GHtii|iov|t |i jo d}n|i |d}|i GHtiit i dd || d GHtiin|io'|o d |iGHtiiqqW|iS( s<Print the result and return the overall count for this file.tpathtrowitcoltcodettextts\St t^s (t_deferred_printtsortt_fmtR+t line_offsetRR9R:t _show_sourcetlentlinestrstriptretsubt _show_pep8tstript file_errors(Rt line_numbertoffsetRPRQtdoctline((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pytget_file_results{s(         (RERFRGRf(((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyRxs(R R7R]RRt ImportErrortNonetpep8t__all__t BaseReportRRKtStandardReportR(((s0/Users/ian7708/sandbox/flake8/flake8/reporter.pyts      aflake8-2.5.4/flake8/run.py00006440_j0000000041712415552077015123 0ustar ian770800000000000000 """ 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.5.4/flake8/tests/00007550_j0000000000012657145314015105 5ustar ian770800000000000000flake8-2.5.4/flake8/tests/__init__.py00006440_j0000000000212415552077017206 0ustar ian770800000000000000# flake8-2.5.4/flake8/tests/__init__.pyc00006440_j0000000021512641044042017344 0ustar ian770800000000000000 ?6Tc@sdS(N((((s6/Users/ian7708/sandbox/flake8/flake8/tests/__init__.pytsflake8-2.5.4/flake8/tests/__pycache__/00007550_j0000000000012657145314017315 5ustar ian770800000000000000flake8-2.5.4/flake8/tests/__pycache__/__init__.cpython-34.pyc00006440_j0000000021112444636551023474 0ustar ian770800000000000000 ?6T@sdS)Nrrr6/Users/ian7708/sandbox/flake8/flake8/tests/__init__.pysflake8-2.5.4/flake8/tests/__pycache__/_test_warnings.cpython-34.pyc00006440_j0000001506512547753734025007 0ustar ian770800000000000000 "BU+ @sdZddlmZddlZddlZddlZyddlmZWnek rnddlZYnXddlm Z ddl m Z Gdddej Z ed krejndS) a _test_warnings.py Tests for the warnings that are emitted by flake8. This module is named _test_warnings instead of test_warnings so that a normal nosetests run does not collect it. The tests in this module pass when they are run alone, but they fail when they are run along with other tests (nosetests --with-isolation doesn't help). In tox.ini, these tests are run separately. )with_statementN)mock)engine) is_windowsc@seZdZdZdZdZddZeddZdd Z gd d d d d Z gd d d ddZ d ddZ d ddZ d ddZd ddZddZddZddZdS)IntegrationTestCaseWarningszjIntegration style tests to check that warnings are issued properly for different command line options.zIThe --jobs option is not available on Windows. Ignoring --jobs arguments.z]The --jobs option is not compatible with supplying input using - . Ignoring --jobs arguments.cCs8tjjt}|jdr4|dd}n|S)z"Return the real path of this file.ZpycN)ospathrealpath__file__endswith)self this_filers z?IntegrationTestCaseWarnings.verify_warnings..css|]}t|jVqdS)N)strmessage)rwarningrrr sz>IntegrationTestCaseWarnings.verify_warnings..) assertEquallenset)rrexpected_warningsZcollected_user_warningsZcollected_warnings_setZexpected_warnings_setrrrverify_warningss      z+IntegrationTestCaseWarnings.verify_warningsFrc Cs|r|jdn|r%d}n |j}dg||g}tjd|,|jtdd\}}|j} WdQX|j| j||| |fS)z:Call check_files and collect any warnings that are issued.z --verbose-flake8zsys.argvZ parse_argvTN) appendrrpatchrrZ check_filesr&Z total_errors) rarglistexplicit_stdincountverboseZ target_fileargvrrreportrrrcheck_files_collect_warningss   z8IntegrationTestCaseWarnings.check_files_collect_warningsc CsJ|jd|d|d|d|\}}}|j|dd||fS)z@Call check_files, and assert that there were no warnings issued.r/r0r1r2r)N)r5r*)rr/r0r1r2rr4rrrrcheck_files_no_warnings_alloweds z;IntegrationTestCaseWarnings.check_files_no_warnings_allowedc Cstjd}|jdd|gd|\}}}tru|jt|jj||j|jdn)|j|jj||j|j|g}|rtr|j |j n|j ||WdQXdS)Nzsys.stdout.flushr/z --jobs=%sr2r) rr.r5rr&intoptionsjobsZ call_countr-windows_warning_textr*)rr9r2ZmockedZguider4rexpected_waringsrrr _job_testers   z'IntegrationTestCaseWarnings._job_testercCs*|jdd||jdd|dS)Nr2 )r<)rr2rrr test_jobs sz%IntegrationTestCaseWarnings.test_jobscCs|jd|dS)Nr2)r6)rr2rrrtest_no_args_no_warningssz4IntegrationTestCaseWarnings.test_no_args_no_warningscsd_fdd}tjd|zjddgddd |\}}}g}|r|jjtr|jjqnj||WdQXj jd dS) Nrcs;jd7_tjd}|jSWdQXdS)Nrr)r1openrread)f)rrr fake_stdinszGIntegrationTestCaseWarnings.test_stdin_jobs_warning..fake_stdinzpep8.stdin_get_valuer/z--jobs=4r0Tr2r) r1rr.r5r-stdin_warning_textrr:r*r&)rr2rErr4rr;r)rrtest_stdin_jobs_warnings  z3IntegrationTestCaseWarnings.test_stdin_jobs_warningcCs|jdddS)Nr2T)r?)rrrrtest_jobs_verbose*sz-IntegrationTestCaseWarnings.test_jobs_verbosecCs|jdddS)Nr2T)r@)rrrr test_no_args_no_warnings_verbose-sz s    p flake8-2.5.4/flake8/tests/__pycache__/test_engine.cpython-34.pyc00006440_j0000002405112641043677024251 0ustar ian770800000000000000 oV" @sddlmZddlZddlZyddlmZWnek r\ddlZYnXddlmZmZm Z m Z ddl Z Gdddej Z ddd ZGd d d ej Zed krejndS) )with_statementN)mock)engineutil __version__reporterc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#S)$ TestEnginecCs i|_dS)N)patches)selfr 9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pysetUpszTestEngine.setUpcCs%t|jjdks!tdS)Nr)lenr itemsAssertionError)r r r r tearDownszTestEngine.tearDowncCs'tj||j|<|j|jS)N)rpatchr start)r rr r r start_patchszTestEngine.start_patchcCsD|jj}x.|jD] \}}|j|j|=qWdS)N)r copyrstop)r r kvr r r stop_patchess zTestEngine.stop_patchesc Cs`tjdK}ggggf|_tj}|jt|tj|jWdQXdS)Nz"flake8.engine._register_extensions) rr return_valuerget_style_guide assertTrue isinstance StyleGuideassert_called_once_with)r Zreg_extgr r r test_get_style_guides  zTestEngine.test_get_style_guidecCstj}tjd}tjdW}g|_d|jj_d|jj_|gf|_tj dd|j WdQX|j i|d6dd6WdQXdS)Nzflake8.engine.StyleGuidezflake8.engine.get_parserZ42Ffoobarparser) rMockrignored_extensionsroptionsZjobsdiffrrr)r mr get_parserr r r test_get_style_guide_kwargs&s  z&TestEngine.test_get_style_guide_kwargsc Cstjd}tj}|jt|dtj|jt|ddkx.|ddD]}|jt|t qiW|j|j WdQXdS)Nzpep8.register_checkr) rrrZ_register_extensionsrrrZ OrderedSetrlistcalled)r Zregister_checkZregistered_extsir r r test_register_extensions2s z#TestEngine.test_register_extensionscCs{tj}tj}ddddg|_d|_d|_tj|||jt|jtdddgdS) NZI123ZI345ZI678ZI910zI345, I678,I910E121E123)r1r2) r MagicMockr&Zenabled_extensionsignorerZ_disable_extensions assertEqualset)r r$r'r r r test_disable_extensions;s    z"TestEngine.test_disable_extensionscCs|jd}|jd}|jd}tj}d d ggggf|_d|_||_tj\}}|j|j|j|j|jd d t |j|j j|j|j j|j |||j |g|j dS) Nz"flake8.engine._register_extensionsz flake8.engine.get_python_versionzpep8.get_parserpyflakes0.7mccabe0.2zPython Versionflake8z.%s (pyflakes: 0.7, mccabe: 0.2) Python Version)r8r9)r:r;)rrr%rrr*rr.rr remove_option add_optionr5r)r reZgpvZpgpr)r$Zhooksr r r test_get_parserGs&     zTestEngine.test_get_parsercCs|jdtjkdS)Non)rrget_python_version)r r r r test_get_python_version`sz"TestEngine.test_get_python_versionc CsOtjd:}d|_tj}t|tjdksEtWdQXdS)Nzflake8.util.is_windowsTF) rrrrrrr BaseQReportr)r Z is_windowsguider r r test_windows_disables_jobsfs  z%TestEngine.test_windows_disables_jobsc CsOtjd:}d|_tj}t|tjdksEtWdQXdS)Nzflake8.util.is_using_stdinTF) rrrrrrrrDr)r Zis_using_stdinrEr r r test_stdin_disables_jobsls  z#TestEngine.test_stdin_disables_jobsc Cs[tjdF}dgggdgf|_tj}d|jjksQtWdQXdS)Nz"flake8.engine._register_extensionsfake_ext0.1a1X)rHrI)rrrrrr'r4r)r r?sgr r r .test_disables_extensions_that_are_not_selectedrs z9TestEngine.test_disables_extensions_that_are_not_selectedc Cstjdn}dgggdgf|_tj\}}|jdgtjd|}d|jjksyt WdQXdS)Nz"flake8.engine._register_extensionsrH0.1a1rJz --select=Xr$)zfake_extrM) rrrrr* parse_argsrr'r4r)r r?r$r'rKr r r &test_enables_off_by_default_extensionsxs z1TestEngine.test_enables_off_by_default_extensionscCsLtjddddg}tj|dd|jj|jjdS)Nspecrequireresolveloadverify_requirementsT)rr%r_load_entry_pointrQrrR)r entry_pointr r r +test_load_entry_point_verifies_requirementss z6TestEngine.test_load_entry_point_verifies_requirementscCsRtjddddg}tj|dd|j|jj|jjdS)NrPrQrRrSrTF) rr%rrU assertFalserQr.rRr)r rVr r r 2test_load_entry_point_does_not_verify_requirementssz=TestEngine.test_load_entry_point_does_not_verify_requirementscCsotjddg}tj|dd|jjdd|jtj|dd|jjdddS)NrPrSrTTrQF)rr%rrUrSr reset_mock)r rVr r r 5test_load_entry_point_passes_require_argument_to_loads  z@TestEngine.test_load_entry_point_passes_require_argument_to_loadN)__name__ __module__ __qualname__r rrrr!r+r0r7r@rCrFrGrLrOrWrYr[r r r r rs"              rzOminous OSError messagecsfddS)Ncs/tdrdSd_tdS)NusedT)hasattrr_OSError)argskwargs) error_numbermessageoserror_side_effectr r rfs z.oserror_generator..oserror_side_effectr )rdrer )rdrerfr oserror_generatorsrgc@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)TestStyleGuidecCs7tjdtj}tjd||_||_dS)NrP styleguide)rr%rZNoQAStyleGuiderri mocked_sg)r Zmocked_styleguider r r r szTestStyleGuide.setUpcCs3|jjddd|jjjddddS)Nzfile.pyparent.)riexcludedrjr)r r r r test_proxies_excludedsz$TestStyleGuide.test_proxies_excludedcCs0t}|jj||jjj|dS)N)objectri init_reportrjr)r rr r r test_proxies_init_reports z'TestStyleGuide.test_proxies_init_reportcCs6|jjddg|jjjdddgdS)Nr"r#paths)ri check_filesrjr)r r r r test_proxies_check_filessz'TestStyleGuide.test_proxies_check_filesc CsZ|jjddddgdddd|jjjd ddddgdddddS) Nzfile.pylines expectedr" line_offsetfilename)ri input_filerjr)r r r r test_proxies_input_files  z&TestStyleGuide.test_proxies_input_filecCsKttjd|jj_|jjddg|jjjt j dS)NzNo space left on devicer"r#) rgerrnoENOSPCrjrs side_effectrirprpep8StandardReport)r r r r -test_check_files_retries_on_specific_OSErrorsszttjd|jj_|jt|jjddgdS)Nz/lol why are we talking about binding to socketsr"r#) rgr~ EADDRINUSErjrsr assertRaisesrari)r r r r *test_check_files_reraises_unknown_OSErrorss z9TestStyleGuide.test_check_files_reraises_unknown_OSErrorscCs>ttjd|jj_|jt|jjddgdS)Nz/lol why are we talking about binding to socketsr"r#) rgr~rrjr|rrrari)r r r r )test_input_file_reraises_unknown_OSErrorss z8TestStyleGuide.test_input_file_reraises_unknown_OSErrorsN) r\r]r^r rnrqrtr}rrrrr r r r rhs      rh__main__) __future__rr~unittestr ImportErrorr<rrrrrTestCaserrgrhr\mainr r r r s   "  G flake8-2.5.4/flake8/tests/__pycache__/test_hooks.cpython-34.pyc00006440_j0000000402212547753733024131 0ustar ian770800000000000000 "BU @sdZddlZddlZyddlmZWnek rRddlZYnXddlZddlmZddZ Gdddej Z e d krej ndS) z-Module containing the tests for flake8.hooks.N)mock) is_windowscCs |jdS)Nzafile.py)endswith)filenamer8/Users/ian7708/sandbox/flake8/flake8/tests/test_hooks.pyexcludedsrc @seZdZerTejjej\ZZ ejj eejj ddZ nejj ejj ddZ e jde jddde jde jdd e e jd d d ejj d d ejj d dgd fe jdddZd S) TestGitHookZfaketmpz os.makedirszflake8.hooks.opencreateTz shutil.rmtreeztempfile.mkdtemp return_valuezflake8.hooks.runNfoozafile.pyzbfile.pyzflake8.hooks.get_style_guidec Gstj}|_tjjddg|j_tjjddg|j_t |_ t j j tjj tjjtjjdd\}}trtjj|\}}ntjj|j|dd}tjj|d} |jj| gdS)Nr zafile.py*zbfile.py)rMockr ospathjoinoptionsexcluderrflake8hooksZgit_hooksplitabspathr splitdrive fake_abs_path check_filesassert_called_once_with) selfget_style_guiderunargsZ style_guidedirnamerZ ignore_driveZtmpdirZtmpfilerrr&test_prepends_tmp_directory_to_excludes    *"z2TestGitHook.test_prepends_tmp_directory_to_exclude)__name__ __module__ __qualname__rrrrgetcwdZ current_driveZ ignore_tailrseprrpatchr#rrrrr s $    r __main__)__doc__runittestr ImportErrorZ flake8.hooksrZ flake8.utilrrTestCaser r$mainrrrrs     ( flake8-2.5.4/flake8/tests/__pycache__/test_integration.cpython-34.pyc00006440_j0000000621512547753733025337 0ustar ian770800000000000000 T @sddlmZddlZddlZyddlmZWnek r\ddlZYnXddlmZddlm Z Gdddej Z dS))with_statementN)mock)engine) is_windowsc@sseZdZdZddZgddddZdd Zd d Zd d ZddZ ddZ dS)IntegrationTestCasezCIntegration style tests to exercise different command line options.cCs8tjjt}|jdr4|dd}n|S)z"Return the real path of this file.ZpycN)ospathrealpath__file__endswith)self this_filer>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyrszIntegrationTestCase.this_fileFrc Cs|rd}n |j}dg||g}tjd|#tjdd}|j}WdQX|j|j|||fS)zCall check_files.-flake8zsys.argv parse_argvTN)rrpatchrget_style_guide check_files assertEqual total_errors)rarglistexplicit_stdincountZ target_fileargv style_guidereportrrrrs  zIntegrationTestCase.check_filescCs|jdS)N)r)rrrr test_no_args%sz IntegrationTestCase.test_no_argsc Cstjd}|jdd|g\}}trl|jt|jj||j|jdn)|j|jj||j|j|WdQXdS)Nzsys.stdout.flushrz --jobs=%sr) rrrrrintoptionsjobs call_count)rr#Zmockedguiderrrr _job_tester)s zIntegrationTestCase._job_testercCs|jd|jddS)N )r&)rrrr test_jobs7s zIntegrationTestCase.test_jobsc sld_fdd}tjd|&jddgdd\}}WdQXjjd dS) Nrcs;jd7_tjd}|jSWdQXdS)Nrr)ropenrread)f)rrr fake_stdin>sz2IntegrationTestCase.test_stdin..fake_stdinzpep8.stdin_get_valuerz--jobs=4rTr)rrrrr)rr.r%rr)rr test_stdin;s  zIntegrationTestCase.test_stdincCsPdd}tjd|,|jddgdddd \}}WdQXdS) NcSsdS)Nz notathing rrrrrr.Isz7IntegrationTestCase.test_stdin_fail..fake_stdinzpep8.stdin_get_valuerz--jobs=4rTrr)rrr)rr.r%rrrrtest_stdin_failHs  z#IntegrationTestCase.test_stdin_failN) __name__ __module__ __qualname____doc__rrr r&r)r/r0rrrrrs      r) __future__rr unittestr ImportErrorrrZ flake8.utilrTestCaserrrrrs   flake8-2.5.4/flake8/tests/__pycache__/test_main.cpython-34.pyc00006440_j0000000141012547753733023730 0ustar ian770800000000000000 "BUp@snddlmZddlZddlZddlmZGdddejZedkrjejndS))with_statementN)mainc@seZdZddZdS)TestMaincCs2tj}tj|}i|_|jdS)N) setuptools Distributionr Flake8Command options_dictrun)self distributioncmdr 7/Users/ian7708/sandbox/flake8/flake8/tests/test_main.pytest_issue_39_regression s  z!TestMain.test_issue_39_regressionN)__name__ __module__ __qualname__rr r r rr s r__main__) __future__runittestrflake8rTestCaserrr r r rs    flake8-2.5.4/flake8/tests/__pycache__/test_pyflakes.cpython-34.pyc00006440_j0000000662512641043677024631 0ustar ian770800000000000000 }GVO @sddlmZddlZddlZddlmZddlmZeddddd gZGd d d ej Z dS) )with_statementN) namedtuple) FlakesCheckerOptionsbuiltinsdoctestsinclude_in_doctestexclude_from_doctestc@speZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)TestFlakesCheckercCstjd|_dS)Nzprint("cookies"))astparsetree)selfr;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pysetUpszTestFlakesChecker.setUpc CsYtdddddddd}tj|t|jd}|jdksUtdS)NrrTrr z cookies.txt)rr parse_optionsr withDoctestAssertionError)roptions flake_checkerrrrtest_doctest_flag_enableds   z+TestFlakesChecker.test_doctest_flag_enabledc CsYtdddddddd}tj|t|jd}|jdksUtdS)NrrFrrr z cookies.txt)rrrr rr)rrrrrrtest_doctest_flag_disableds   z,TestFlakesChecker.test_doctest_flag_disabledc CsYtdddddddd}tj|t|jd}|jd ksUtdS) NrrTrrr zcookies.txt,hungry/cookies.txtz ./cookies.txtF)rrrr rr)rrrrrr&test_doctest_flag_enabled_exclude_file$s   z8TestFlakesChecker.test_doctest_flag_enabled_exclude_filec CsYtdddddddd}tj|t|jd}|jd ksUtdS) NrrFrz./cookies.txt,cake_yuck.txtr rz ./cookies.txtT)rrrr rr)rrrrrr'test_doctest_flag_disabled_include_file-s   z9TestFlakesChecker.test_doctest_flag_disabled_include_filec CsYtdddddddd}tj|t|jd}|jdksUtdS) NrrFrz ./cookies.txtr z./T)rrrr rr)rrrrrr3test_doctest_flag_disabled_include_file_exclude_dir5s   zETestFlakesChecker.test_doctest_flag_disabled_include_file_exclude_dirc CsYtdddddddd}tj|t|jd}|jdksUtdS)NrrFrz./r z ./cookies.txt)rrrr rr)rrrrrr3test_doctest_flag_disabled_include_dir_exclude_file=s   zETestFlakesChecker.test_doctest_flag_disabled_include_dir_exclude_filec Cs;tdddddddd}|jttj|dS)NrrFrz ./cookies.txtr z./cookies.txt,cake_yuck.txt)r assertRaises ValueErrorrr)rrrrr:test_doctest_flag_disabled_include_file_exclude_file_errorEs zLTestFlakesChecker.test_doctest_flag_disabled_include_file_exclude_file_errorN) __name__ __module__ __qualname__rrrrrrrr rrrrr s       r ) __future__rr unittest collectionsrZflake8._pyflakesrrTestCaser rrrrs    flake8-2.5.4/flake8/tests/__pycache__/test_reporter.cpython-34.pyc00006440_j0000000364412641043677024653 0ustar ian770800000000000000 oVe @sddlmZddlZddlZyddlmZWnek r\ddlZYnXddlmZddZGdddej Z dS) )with_statementN)mock)reportercs>Gfdddtj}tj}d|_||S)Ncs"eZdZfddZdS)z2ioerror_report_factory..IOErrorBaseQReportcstddS)NzFake bad pipe exception)IOError)self) errno_code;/Users/ian7708/sandbox/flake8/flake8/tests/test_reporter.py _process_mainsz@ioerror_report_factory..IOErrorBaseQReport._process_mainN)__name__ __module__ __qualname__r r)rrr IOErrorBaseQReports r)r BaseQReportr MagicMockjobs)rroptionsr)rr ioerror_report_factory s  rc@s(eZdZddZddZdS)TestBaseQReportc CsCttj}y|jWntk r>|jdYnXdS)zs    flake8-2.5.4/flake8/tests/__pycache__/test_util.cpython-34.pyc00006440_j0000000707212641043677023765 0ustar ian770800000000000000 oV@sRddlZddlmZGdddejZedkrNejndS)N)option_normalizerc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdS) TestOptionSerializercCstd}|j|dS)N1)r assertTrue)selfoptionr7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pytest_1_is_trues z#TestOptionSerializer.test_1_is_truecCstd}|j|dS)NT)rr)rrrrr test_T_is_true s z#TestOptionSerializer.test_T_is_truecCs td}|j|ddS)NTRUET)rr)rrrrr test_TRUE_is_trues z&TestOptionSerializer.test_TRUE_is_truecCstd}|j|dS)NON)rr)rrrrr test_ON_is_trues z$TestOptionSerializer.test_ON_is_truecCstd}|j|dS)Nt)rr)rrrrr test_t_is_trues z#TestOptionSerializer.test_t_is_truecCstd}|j|dS)Ntrue)rr)rrrrr test_true_is_trues z&TestOptionSerializer.test_true_is_truecCstd}|j|dS)Non)rr)rrrrr test_on_is_true s z$TestOptionSerializer.test_on_is_truecCstd}|j|dS)N0)r assertFalse)rrrrr test_0_is_false$s z$TestOptionSerializer.test_0_is_falsecCstd}|j|dS)NF)rr)rrrrr test_F_is_false(s z$TestOptionSerializer.test_F_is_falsecCstd}|j|dS)NFALSE)rr)rrrrr test_FALSE_is_false,s z(TestOptionSerializer.test_FALSE_is_falsecCstd}|j|dS)NOFF)rr)rrrrr test_OFF_is_false0s z&TestOptionSerializer.test_OFF_is_falsecCstd}|j|dS)Nf)rr)rrrrr test_f_is_false4s z$TestOptionSerializer.test_f_is_falsecCstd}|j|dS)Nfalse)rr)rrrrr test_false_is_false8s z(TestOptionSerializer.test_false_is_falsecCstd}|j|dS)Noff)rr)rrrrr test_off_is_false<s z&TestOptionSerializer.test_off_is_falsecCsddddg}td}|j||td}|j||td}|j||td}|j||dS) NZF401ZF402ZF403ZF404zF401,F402,F403,F404zF401 ,F402 ,F403 ,F404zF401, F402, F403, F404zP F401, F402, F403, F404, )r assertEqual)ranswerrrrr test_parses_lists@s    z&TestOptionSerializer.test_parses_listsN)__name__ __module__ __qualname__r r rrrrrrrrrr!r#r%r(rrrr rs               r__main__)unittestZ flake8.utilrTestCaserr)mainrrrr s O flake8-2.5.4/flake8/tests/_test_warnings.py00006440_j0000002566412520516042020507 0ustar ian770800000000000000""" _test_warnings.py Tests for the warnings that are emitted by flake8. This module is named _test_warnings instead of test_warnings so that a normal nosetests run does not collect it. The tests in this module pass when they are run alone, but they fail when they are run along with other tests (nosetests --with-isolation doesn't help). In tox.ini, these tests are run separately. """ from __future__ import with_statement import os import warnings import unittest try: from unittest import mock except ImportError: import mock # < PY33 from flake8 import engine from flake8.util import is_windows # The Problem # ------------ # # Some of the tests in this module pass when this module is run on its own, but # they fail when this module is run as part of the whole test suite. These are # the problematic tests: # # test_jobs_verbose # test_stdin_jobs_warning # # On some platforms, the warnings.capture_warnings function doesn't work # properly when run with the other flake8 tests. It drops some warnings, even # though the warnings filter is set to 'always'. However, when run separately, # these tests pass. # # This problem only occurs on Windows, with Python 3.3 and older. Maybe it's # related to PEP 446 - Inheritable file descriptors? # # # # # Things that didn't work # ------------ # # Nose --attr # I tried using the nosetests --attr feature to run the tests separately. I # put the following in setup.cfg # # [nosetests] # atttr=!run_alone # # Then I added a tox section thst did this # # nosetests --attr=run_alone # # However, the command line --attr would not override the config file --attr, # so the special tox section wound up runing all the tests, and failing. # # # # Nose --with-isolation # The nosetests --with-isolation flag did not help. # # # # unittest.skipIf # I tried decorating the problematic tests with the unittest.skipIf # decorator. # # @unittest.skipIf(is_windows() and sys.version_info < (3, 4), # "Fails on Windows with Python < 3.4 when run with other" # " tests.") # # The idea is, skip the tests in the main test run, on affected platforms. # Then, only on those platforms, come back in later and run the tests # separately. # # I added a new stanza to tox.ini, to run the tests separately on the # affected platforms. # # nosetests --no-skip # # I ran in to a bug in the nosetests skip plugin. It would report the test as # having been run, but it would not actually run the test. So, when run with # --no-skip, the following test would be reported as having run and passed! # # @unittest.skip("This passes o_o") # def test_should_fail(self): # assert 0 # # This bug has been reported here: # "--no-skip broken with Python 2.7" # https://github.com/nose-devs/nose/issues/512 # # # # py.test # # I tried using py.test, and its @pytest.mark.xfail decorator. I added some # separate stanzas in tox, and useing the pytest --runxfail option to run the # tests separately. This allows us to run all the tests together, on # platforms that allow it. On platforms that don't allow us to run the tests # all together, this still runs all the tests, but in two separate steps. # # This is the same solution as the nosetests --no-skip solution I described # above, but --runxfail does not have the same bug as --no-skip. # # This has the advantage that all tests are discoverable by default, outside # of tox. However, nose does not recognize the pytest.mark.xfail decorator. # So, if a user runs nosetests, it still tries to run the problematic tests # together with the rest of the test suite, causing them to fail. # # # # # # # Solution # ------------ # Move the problematic tests to _test_warnings.py, so nose.collector will not # find them. Set up a separate section in tox.ini that runs this: # # nosetests flake8.tests._test_warnings # # This allows all tests to pass on all platforms, when run through tox. # However, it means that, even on unaffected platforms, the problematic tests # are not discovered and run outside of tox (if the user just runs nosetests # manually, for example). class IntegrationTestCaseWarnings(unittest.TestCase): """Integration style tests to check that warnings are issued properly for different command line options.""" windows_warning_text = ("The --jobs option is not available on Windows." " Ignoring --jobs arguments.") stdin_warning_text = ("The --jobs option is not compatible with" " supplying input using - . Ignoring --jobs" " arguments.") def this_file(self): """Return the real path of this file.""" this_file = os.path.realpath(__file__) if this_file.endswith("pyc"): this_file = this_file[:-1] return this_file @staticmethod def get_style_guide_with_warnings(engine, *args, **kwargs): """ Return a style guide object (obtained by calling engine.get_style_guide) and a list of the warnings that were raised in the process. Note: not threadsafe """ # Note # https://docs.python.org/2/library/warnings.html # # The catch_warnings manager works by replacing and then later # restoring the module's showwarning() function and internal list of # filter specifications. This means the context manager is modifying # global state and therefore is not thread-safe with warnings.catch_warnings(record=True) as collected_warnings: # Cause all warnings to always be triggered. warnings.simplefilter("always") # Get the style guide style_guide = engine.get_style_guide(*args, **kwargs) # Now that the warnings have been collected, return the style guide and # the warnings. return (style_guide, collected_warnings) def verify_warnings(self, collected_warnings, expected_warnings): """ Verifies that collected_warnings is a sequence that contains user warnings that match the sequence of string values passed in as expected_warnings. """ if expected_warnings is None: expected_warnings = [] collected_user_warnings = [w for w in collected_warnings if issubclass(w.category, UserWarning)] self.assertEqual(len(collected_user_warnings), len(expected_warnings)) collected_warnings_set = set(str(warning.message) for warning in collected_user_warnings) expected_warnings_set = set(expected_warnings) self.assertEqual(collected_warnings_set, expected_warnings_set) def check_files_collect_warnings(self, arglist=[], explicit_stdin=False, count=0, verbose=False): """Call check_files and collect any warnings that are issued.""" if verbose: arglist.append('--verbose') if explicit_stdin: target_file = "-" else: target_file = self.this_file() argv = ['flake8'] + arglist + [target_file] with mock.patch("sys.argv", argv): (style_guide, collected_warnings, ) = self.get_style_guide_with_warnings(engine, parse_argv=True) report = style_guide.check_files() self.assertEqual(report.total_errors, count) return style_guide, report, collected_warnings def check_files_no_warnings_allowed(self, arglist=[], explicit_stdin=False, count=0, verbose=False): """Call check_files, and assert that there were no warnings issued.""" (style_guide, report, collected_warnings, ) = self.check_files_collect_warnings(arglist=arglist, explicit_stdin=explicit_stdin, count=count, verbose=verbose) self.verify_warnings(collected_warnings, expected_warnings=None) return style_guide, report def _job_tester(self, jobs, verbose=False): # mock stdout.flush so we can count the number of jobs created with mock.patch('sys.stdout.flush') as mocked: (guide, report, collected_warnings, ) = self.check_files_collect_warnings( arglist=['--jobs=%s' % jobs], verbose=verbose) if is_windows(): # The code path where guide.options.jobs gets converted to an # int is not run on windows. So, do the int conversion here. self.assertEqual(int(guide.options.jobs), jobs) # On windows, call count is always zero. self.assertEqual(mocked.call_count, 0) else: self.assertEqual(guide.options.jobs, jobs) self.assertEqual(mocked.call_count, jobs) expected_warings = [] if verbose and is_windows(): expected_warings.append(self.windows_warning_text) self.verify_warnings(collected_warnings, expected_warings) def test_jobs(self, verbose=False): self._job_tester(2, verbose=verbose) self._job_tester(10, verbose=verbose) def test_no_args_no_warnings(self, verbose=False): self.check_files_no_warnings_allowed(verbose=verbose) def test_stdin_jobs_warning(self, verbose=False): self.count = 0 def fake_stdin(): self.count += 1 with open(self.this_file(), "r") as f: return f.read() with mock.patch("pep8.stdin_get_value", fake_stdin): (style_guide, report, collected_warnings, ) = self.check_files_collect_warnings(arglist=['--jobs=4'], explicit_stdin=True, verbose=verbose) expected_warings = [] if verbose: expected_warings.append(self.stdin_warning_text) if is_windows(): expected_warings.append(self.windows_warning_text) self.verify_warnings(collected_warnings, expected_warings) self.assertEqual(self.count, 1) def test_jobs_verbose(self): self.test_jobs(verbose=True) def test_no_args_no_warnings_verbose(self): self.test_no_args_no_warnings(verbose=True) def test_stdin_jobs_warning_verbose(self): self.test_stdin_jobs_warning(verbose=True) if __name__ == '__main__': unittest.main() flake8-2.5.4/flake8/tests/_test_warnings.pyc00006440_j0000001563412641043671020655 0ustar ian770800000000000000 "BUc@sdZddlmZddlZddlZddlZyddlmZWnek rmddlZnXddlm Z ddl m Z dej fdYZ ed krejndS( s _test_warnings.py Tests for the warnings that are emitted by flake8. This module is named _test_warnings instead of test_warnings so that a normal nosetests run does not collect it. The tests in this module pass when they are run alone, but they fail when they are run along with other tests (nosetests --with-isolation doesn't help). In tox.ini, these tests are run separately. i(twith_statementN(tmock(tengine(t is_windowstIntegrationTestCaseWarningscBseZdZdZdZdZedZdZge de dZ ge de dZ e d Z e d Z e d Ze d Zd ZdZdZRS(sjIntegration style tests to check that warnings are issued properly for different command line options.sIThe --jobs option is not available on Windows. Ignoring --jobs arguments.s]The --jobs option is not compatible with supplying input using - . Ignoring --jobs arguments.cCs2tjjt}|jdr.|d }n|S(s"Return the real path of this file.tpyci(tostpathtrealpatht__file__tendswith(tselft this_file((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyR s cOsDtjdt&}tjd|j||}WdQX||fS(s Return a style guide object (obtained by calling engine.get_style_guide) and a list of the warnings that were raised in the process. Note: not threadsafe trecordtalwaysN(twarningstcatch_warningstTruet simplefiltertget_style_guide(Rtargstkwargstcollected_warningst style_guide((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pytget_style_guide_with_warningss cCs|dkrg}ng|D]}t|jtr|^q}|jt|t|td|D}t|}|j||dS(s Verifies that collected_warnings is a sequence that contains user warnings that match the sequence of string values passed in as expected_warnings. css|]}t|jVqdS(N(tstrtmessage(t.0twarning((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pys sN(tNonet issubclasstcategoryt UserWarningt assertEqualtlentset(R Rtexpected_warningstwtcollected_user_warningstcollected_warnings_settexpected_warnings_set((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pytverify_warningss       ic Cs|r|jdn|r%d}n |j}dg||g}tjd|,|jtdt\}}|j} WdQX|j| j ||| |fS(s:Call check_files and collect any warnings that are issued.s --verboset-tflake8ssys.argvt parse_argvN( tappendR RtpatchRRRt check_filesR!t total_errors( R targlisttexplicit_stdintcounttverboset target_filetargvRRtreport((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pytcheck_files_collect_warningss   c CsJ|jd|d|d|d|\}}}|j|dd||fS(s@Call check_files, and assert that there were no warnings issued.R1R2R3R4R$N(R8R)R(R R1R2R3R4RR7R((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pytcheck_files_no_warnings_alloweds c Cstjd}|jdd|gd|\}}}tru|jt|jj||j|jdn)|j|jj||j|j|g}|rtr|j |j n|j ||WdQXdS(Nssys.stdout.flushR1s --jobs=%sR4i( RR.R8RR!tinttoptionstjobst call_countR-twindows_warning_textR)(R R<R4tmockedtguideR7Rtexpected_warings((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyt _job_testers   cCs*|jdd||jdd|dS(NiR4i (RB(R R4((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyt test_jobs scCs|jd|dS(NR4(R9(R R4((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyttest_no_args_no_warningssc sd_fd}tjd|zjddgdtd|\}}}g}|r|jjtr|jjqnj ||WdQXj jddS( Nics;jd7_tjd}|jSWdQXdS(Nitr(R3topenR tread(tf(R (s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyt fake_stdinsspep8.stdin_get_valueR1s--jobs=4R2R4i( R3RR.R8RR-tstdin_warning_textRR>R)R!(R R4RIRR7RRA((R s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyttest_stdin_jobs_warnings  cCs|jdtdS(NR4(RCR(R ((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyttest_jobs_verbose*scCs|jdtdS(NR4(RDR(R ((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyt test_no_args_no_warnings_verbose-scCs|jdtdS(NR4(RKR(R ((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyttest_stdin_jobs_warning_verbose0s(t__name__t __module__t__doc__R>RJR t staticmethodRR)tFalseR8R9RBRCRDRKRLRMRN(((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyRs*         t__main__(RQt __future__RRRtunittestRt ImportErrorR+Rt flake8.utilRtTestCaseRROtmain(((s</Users/ian7708/sandbox/flake8/flake8/tests/_test_warnings.pyt s    p flake8-2.5.4/flake8/tests/test_engine.py00006440_j0000002135712656732356020002 0ustar ian770800000000000000from __future__ import with_statement import errno import unittest try: from unittest import mock except ImportError: import mock # < PY33 from flake8 import engine, util, __version__, reporter import pep8 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: m.ignored_extensions = [] StyleGuide.return_value.options.jobs = '42' StyleGuide.return_value.options.diff = False 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_exts = engine._register_extensions() self.assertTrue(isinstance(registered_exts[0], util.OrderedSet)) self.assertTrue(len(registered_exts[0]) > 0) for i in registered_exts[1:]: self.assertTrue(isinstance(i, list)) self.assertTrue(register_check.called) def test_disable_extensions(self): parser = mock.MagicMock() options = mock.MagicMock() parser.ignored_extensions = ['I123', 'I345', 'I678', 'I910'] options.enable_extensions = 'I345,\nI678,I910' options.ignore = ('E121', 'E123') engine._disable_extensions(parser, options) self.assertEqual(set(options.ignore), set(['E121', 'E123', 'I123'])) 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 self.assertTrue(re.called) self.assertTrue(gpv.called) pgp.assert_called_once_with( 'flake8', '%s (pyflakes: 0.7, mccabe: 0.2) Python Version' % __version__) self.assertTrue(m.remove_option.called) self.assertTrue(m.add_option.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. def test_windows_disables_jobs(self): with mock.patch('flake8.util.is_windows') as is_windows: is_windows.return_value = True guide = engine.get_style_guide() assert isinstance(guide, reporter.BaseQReport) is False def test_stdin_disables_jobs(self): with mock.patch('flake8.util.is_using_stdin') as is_using_stdin: is_using_stdin.return_value = True guide = engine.get_style_guide() assert isinstance(guide, reporter.BaseQReport) is False def test_disables_extensions_that_are_not_selected(self): with mock.patch('flake8.engine._register_extensions') as re: re.return_value = ([('fake_ext', '0.1a1')], [], [], ['X']) sg = engine.get_style_guide() assert 'X' in sg.options.ignore def test_enables_off_by_default_extensions(self): with mock.patch('flake8.engine._register_extensions') as re: re.return_value = ([('fake_ext', '0.1a1')], [], [], ['X']) parser, options = engine.get_parser() parser.parse_args(['--select=X']) sg = engine.StyleGuide(parser=parser) assert 'X' not in sg.options.ignore def test_load_entry_point_verifies_requirements(self): entry_point = mock.Mock(spec=['require', 'resolve', 'load']) engine._load_entry_point(entry_point, verify_requirements=True) entry_point.require.assert_called_once_with() entry_point.resolve.assert_called_once_with() def test_load_entry_point_does_not_verify_requirements(self): entry_point = mock.Mock(spec=['require', 'resolve', 'load']) engine._load_entry_point(entry_point, verify_requirements=False) self.assertFalse(entry_point.require.called) entry_point.resolve.assert_called_once_with() def test_load_entry_point_passes_require_argument_to_load(self): entry_point = mock.Mock(spec=['load']) engine._load_entry_point(entry_point, verify_requirements=True) entry_point.load.assert_called_once_with(require=True) entry_point.reset_mock() engine._load_entry_point(entry_point, verify_requirements=False) entry_point.load.assert_called_once_with(require=False) def oserror_generator(error_number, message='Ominous OSError message'): def oserror_side_effect(*args, **kwargs): if hasattr(oserror_side_effect, 'used'): return oserror_side_effect.used = True raise OSError(error_number, message) return oserror_side_effect class TestStyleGuide(unittest.TestCase): def setUp(self): mocked_styleguide = mock.Mock(spec=engine.NoQAStyleGuide) self.styleguide = engine.StyleGuide(styleguide=mocked_styleguide) self.mocked_sg = mocked_styleguide def test_proxies_excluded(self): self.styleguide.excluded('file.py', parent='.') self.mocked_sg.excluded.assert_called_once_with('file.py', parent='.') def test_proxies_init_report(self): reporter = object() self.styleguide.init_report(reporter) self.mocked_sg.init_report.assert_called_once_with(reporter) def test_proxies_check_files(self): self.styleguide.check_files(['foo', 'bar']) self.mocked_sg.check_files.assert_called_once_with( paths=['foo', 'bar'] ) def test_proxies_input_file(self): self.styleguide.input_file('file.py', lines=[9, 10], expected='foo', line_offset=20) self.mocked_sg.input_file.assert_called_once_with(filename='file.py', lines=[9, 10], expected='foo', line_offset=20) def test_check_files_retries_on_specific_OSErrors(self): self.mocked_sg.check_files.side_effect = oserror_generator( errno.ENOSPC, 'No space left on device' ) self.styleguide.check_files(['foo', 'bar']) self.mocked_sg.init_report.assert_called_once_with(pep8.StandardReport) def test_input_file_retries_on_specific_OSErrors(self): self.mocked_sg.input_file.side_effect = oserror_generator( errno.ENOSPC, 'No space left on device' ) self.styleguide.input_file('file.py') self.mocked_sg.init_report.assert_called_once_with(pep8.StandardReport) def test_check_files_reraises_unknown_OSErrors(self): self.mocked_sg.check_files.side_effect = oserror_generator( errno.EADDRINUSE, 'lol why are we talking about binding to sockets' ) self.assertRaises(OSError, self.styleguide.check_files, ['foo', 'bar']) def test_input_file_reraises_unknown_OSErrors(self): self.mocked_sg.input_file.side_effect = oserror_generator( errno.EADDRINUSE, 'lol why are we talking about binding to sockets' ) self.assertRaises(OSError, self.styleguide.input_file, ['foo', 'bar']) if __name__ == '__main__': unittest.main() flake8-2.5.4/flake8/tests/test_engine.pyc00006440_j0000002703112641044042020116 0ustar ian770800000000000000 oVc @sddklZddkZddkZyddklZWnej oddkZnXddklZlZl Z l Z ddk Z dei fdYZ ddZd ei fd YZed joeindS( i(twith_statementN(tmock(tenginetutilt __version__treportert TestEnginecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZRS(cCs h|_dS(N(tpatches(tself((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pytsetUpscCs't|iidjptdS(Ni(tlenRtitemstAssertionError(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttearDownscCs'ti||i|<|i|iS(N(RtpatchRtstart(RR((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt start_patchscCsD|ii}x.|iD] \}}|i|i|=qWdS(N(RtcopyR tstop(RRtktv((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt stop_patchess   cCsttidii}zQ|~}ggggf|_ti}|it|ti |i WdQXdS(Ns"flake8.engine._register_extensions( RRt__exit__t __enter__t return_valueRtget_style_guidet assertTruet isinstancet StyleGuidetassert_called_once_with(Rt_[1]treg_exttg((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_get_style_guides & c Csti}tidii}z|~}tidii}z]|~}g|_d|ii_t |ii_ |gf|_t i dd|i WdQX|i h|d6dd6WdQXdS(Nsflake8.engine.StyleGuidesflake8.engine.get_parsert42tfootbartparser(RtMockRRRtignored_extensionsRtoptionstjobstFalsetdiffRRR(RtmRRt_[2]t get_parser((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_get_style_guide_kwargs&s && c Cstidii}z|~}ti}|it|dti |it |ddjx(|dD]}|it|t qwW|i|i WdQXdS(Nspep8.register_checkii( RRRRRt_register_extensionsRRRt OrderedSetR tlisttcalled(RRtregister_checktregistered_extsti((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_register_extensions2s&  cCs{ti}ti}ddddg|_d|_d|_ti|||it|itdddgdS( NtI123tI345tI678tI910sI345, I678,I910tE121tE123(R<R=( Rt MagicMockR'tenabled_extensionstignoreRt_disable_extensionst assertEqualtset(RR%R(((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_disable_extensions;s    cCs|id}|id}|id}ti}d d ggggf|_d|_||_ti\}}|i|i|i|i|id d t |i|i i|i|i i|i |||i |g|i 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(REs0.7(RFs0.2(RRR&RRR.RR3RRt remove_optiont add_optionRBR(RtretgpvtpgpR,R%thooks((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_get_parserGs&     cCs|idtijdS(Nton(RRtget_python_version(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_get_python_version`scCsetidii}zB|~}t|_ti}t|t i t jpt WdQXdS(Nsflake8.util.is_windows( RRRRtTrueRRRRRt BaseQReportR*R (RRt is_windowstguide((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_windows_disables_jobsfs&  cCsetidii}zB|~}t|_ti}t|t i t jpt WdQXdS(Nsflake8.util.is_using_stdin( RRRRRRRRRRRRSR*R (RRtis_using_stdinRU((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_stdin_disables_jobsls&  cCsqtidii}zN|~}dgggdgf|_ti}d|iijpt WdQXdS(Ns"flake8.engine._register_extensionstfake_exts0.1a1tX(RYs0.1a1( RRRRRRRR(R@R (RRRJtsg((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt.test_disables_extensions_that_are_not_selectedrs& cCstidii}zv|~}dgggdgf|_ti\}}|idgtid|}d|i i jpt WdQXdS(Ns"flake8.engine._register_extensionsRYs0.1a1RZs --select=XR%(sfake_exts0.1a1( RRRRRRR.t parse_argsRR(R@R (RRRJR%R(R[((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt&test_enables_off_by_default_extensionsxs &cCsLtiddddg}ti|dt|ii|iidS(Ntspectrequiretresolvetloadtverify_requirements(RR&Rt_load_entry_pointRRR`RRa(Rt entry_point((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt+test_load_entry_point_verifies_requirementss cCsRtiddddg}ti|dt|i|ii|ii dS(NR_R`RaRbRc( RR&RRdR*t assertFalseR`R3RaR(RRe((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt2test_load_entry_point_does_not_verify_requirementsscCsotiddg}ti|dt|iidt|iti|dt|iidtdS(NR_RbRcR`( RR&RRdRRRbRt reset_mockR*(RRe((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt5test_load_entry_point_passes_require_argument_to_loads  (t__name__t __module__R R RRR!R/R7RDRNRQRVRXR\R^RfRhRj(((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyRs"             sOminous OSError messagecsfdS(Ncs1tdodSt_tdS(Ntused(thasattrRRRmtOSError(targstkwargs(toserror_side_effecttmessaget error_number(s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyRrs ((RtRs((RsRtRrs9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pytoserror_generatorstTestStyleGuidecBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCs7tidti}tid||_||_dS(NR_t styleguide(RR&RtNoQAStyleGuideRRwt mocked_sg(Rtmocked_styleguide((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyR scCs3|iiddd|iiiddddS(Nsfile.pytparentt.(RwtexcludedRyR(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_proxies_excludedscCs0t}|ii||iii|dS(N(tobjectRwt init_reportRyR(RR((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_proxies_init_reports cCs6|iiddg|iiidddgdS(NR#R$tpaths(Rwt check_filesRyR(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_proxies_check_filessc CsZ|iiddddgdddd|iiid ddddgdddddS( Nsfile.pytlinesi i texpectedR#t line_offsetitfilename(Rwt input_fileRyR(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyttest_proxies_input_files  cCsKttid|ii_|iiddg|iiit i dS(NsNo space left on deviceR#R$( RuterrnotENOSPCRyRt side_effectRwRRtpep8tStandardReport(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt-test_check_files_retries_on_specific_OSErrorsscCsEttid|ii_|iid|iiit i dS(NsNo space left on devicesfile.py( RuRRRyRRRwRRRR(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt,test_input_file_retries_on_specific_OSErrorsscCs>ttid|ii_|it|iiddgdS(Ns/lol why are we talking about binding to socketsR#R$( RuRt EADDRINUSERyRRt assertRaisesRoRw(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt*test_check_files_reraises_unknown_OSErrorss cCs>ttid|ii_|it|iiddgdS(Ns/lol why are we talking about binding to socketsR#R$( RuRRRyRRRRoRw(R((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyt)test_input_file_reraises_unknown_OSErrorss ( RkRlR R~RRRRRRR(((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyRvs     t__main__(t __future__RRtunittestRt ImportErrorRGRRRRRtTestCaseRRuRvRktmain(((s9/Users/ian7708/sandbox/flake8/flake8/tests/test_engine.pyts  "  G flake8-2.5.4/flake8/tests/test_git_hook.pyc00006440_j0000001031412465701551020461 0ustar ian770800000000000000 3Tc@shddlZddlZddlZddlZeedZddZdejfdYZ dS(iNcCsU|jdr,| r,ddddggfS|jdrE|rEd Std dS( Nsgit diff-indexis ignore.pysmyproject/main.pysmyproject/test/test.pysgit showsdummy standard outputsdummy standard errort side_effect(isdummy standard outputsdummy standard error(t startswithtNotImplementedError(tcommandt raw_outputtdecode((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_git_hook.pyRs   tcCsVtjd|}g|jdD]}|d^q"dgd}||jj_|S(Nt read_datas i (tmockt mock_opentsplittNonet return_valuetreadlineR(Rtmotxtlines((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_git_hook.pyR s 1tTestFixExcludecBseZdZdZejdejjejj dejdejdddejdd e d Z ejdejjejj dejdddejdd e d Z RS( s[The scenario used to test fix_exclude is as follows. There is a git repo with two files: ignore.py, myproject/main.py and myproject/test/test.py. We want to run flake over myproject/main.py only. To achieve this, we add myproject/test/test.py to the list of exclude patterns -- in real life, this is done by editing configuration files (http://flake8.readthedocs.org/en/latest/config.html), but for the test we just mock it. Without the fix, since the exclude pattern for test.py contains a slash, pep8.read_config will convert it to an absolute path, using os.curdir as a base. This behavior causes pep8.filename_match to fail, since our files will be in tmpdir, not os.curdir. The end result is flake8 ends up checking myproject/test/test.py, which is something we don't want. With the fix, the exclude pattern is set correctly, and flake8 only checks one file: myproject/main.py. The exclude pattern for ignore.py is not affected by the fix, since it doesn't contain a slash, and isn't converted to an absolute path by pep8.read_config. cCs d|_dS(Ns3[flake8] exclude = ignore.py,myproject/test/test.py(tconfig(tself((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_git_hook.pytsetUp9ss os.makedirst check_filessflake8.hooks.fix_excludesflake8.hooks.mkdtempR s/tmpsflake8.hooks.runRc Cstjdtd|jdt7tjdtjdttjjWdQXWdQX|j|j d|j dd}|GH|jt |ddS(NsConfigParser.openRtcreatesflake8.hooks.openiii( RtpatchR RtTruetflake8thookstgit_hookt assertEqualst call_countt call_argstlen(Rtmock_runt mock_mkdtemptmock_fix_excludetmock_check_filest mock_makedirstargs((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_git_hook.pyttest_without_fix<s  c Cstjdtd|jdt7tjdtjdttjjWdQXWdQX|j|j d|j dd}|GH|jt |ddS(NsConfigParser.openRRsflake8.hooks.openii( RRR RRRRRRRRR(RR R!R#R$R%((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_git_hook.pyt test_with_fixPs  ( t__name__t __module__t__doc__RRRtobjectRtenginet StyleGuideRR&R'(((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_git_hook.pyR"s   * ( tunittestRt flake8.hooksRt flake8.enginetFalseRR tTestCaseR(((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_git_hook.pyts     flake8-2.5.4/flake8/tests/test_hooks.py00006440_j0000000421012520516042017623 0ustar ian770800000000000000"""Module containing the tests for flake8.hooks.""" import os import unittest try: from unittest import mock except ImportError: import mock import flake8.hooks from flake8.util import is_windows def excluded(filename): return filename.endswith('afile.py') class TestGitHook(unittest.TestCase): if is_windows: # On Windows, absolute paths start with a drive letter, for example C: # Here we build a fake absolute path starting with the current drive # letter, for example C:\fake\temp current_drive, ignore_tail = os.path.splitdrive(os.getcwd()) fake_abs_path = os.path.join(current_drive, os.path.sep, 'fake', 'tmp') else: fake_abs_path = os.path.join(os.path.sep, 'fake', 'tmp') @mock.patch('os.makedirs') @mock.patch('flake8.hooks.open', create=True) @mock.patch('shutil.rmtree') @mock.patch('tempfile.mkdtemp', return_value=fake_abs_path) @mock.patch('flake8.hooks.run', return_value=(None, [os.path.join('foo', 'afile.py'), os.path.join('foo', 'bfile.py')], None)) @mock.patch('flake8.hooks.get_style_guide') def test_prepends_tmp_directory_to_exclude(self, get_style_guide, run, *args): style_guide = get_style_guide.return_value = mock.Mock() style_guide.options.exclude = [os.path.join('foo', 'afile.py')] style_guide.options.filename = [os.path.join('foo', '*')] style_guide.excluded = excluded flake8.hooks.git_hook() dirname, filename = os.path.split( os.path.abspath(os.path.join('foo', 'bfile.py'))) if is_windows: # In Windows, the absolute path in dirname will start with a drive # letter. Here, we discad the drive letter. ignore_drive, dirname = os.path.splitdrive(dirname) tmpdir = os.path.join(self.fake_abs_path, dirname[1:]) tmpfile = os.path.join(tmpdir, 'bfile.py') style_guide.check_files.assert_called_once_with([tmpfile]) if __name__ == '__main__': unittest.main() flake8-2.5.4/flake8/tests/test_hooks.pyc00006440_j0000000451312641044042017774 0ustar ian770800000000000000 "BUc @sdZddkZddkZyddklZWnej oddkZnXddkZddklZdZ dei fdYZ e djoei ndS( s-Module containing the tests for flake8.hooks.iN(tmock(t is_windowscCs |idS(Nsafile.py(tendswith(tfilename((s8/Users/ian7708/sandbox/flake8/flake8/tests/test_hooks.pytexcludedst TestGitHookc BseZeoCeiiei\ZZeii eeii ddZ neii eii ddZ e i de i ddee i de i dde e i dddeii d d eii d d gdfe i d d ZRS(tfakettmps os.makedirssflake8.hooks.opentcreates shutil.rmtreestempfile.mkdtempt return_valuesflake8.hooks.runtfoosafile.pysbfile.pysflake8.hooks.get_style_guidec Gsti}|_tiiddg|i_tiiddg|i_t |_ t i i tii tiitiidd\}}totii|\}}ntii|i|d}tii|d} |ii| gdS(NR safile.pyt*sbfile.pyi(RtMockR tostpathtjointoptionstexcludeRRtflake8thookstgit_hooktsplittabspathRt splitdrivet fake_abs_patht check_filestassert_called_once_with( tselftget_style_guidetruntargst style_guidetdirnameRt ignore_drivettmpdirttmpfile((s8/Users/ian7708/sandbox/flake8/flake8/tests/test_hooks.pyt&test_prepends_tmp_directory_to_excludes    *N(t__name__t __module__RR RRtgetcwdt current_drivet ignore_tailRtsepRRtpatchtTruetNoneR$(((s8/Users/ian7708/sandbox/flake8/flake8/tests/test_hooks.pyRs%    t__main__(t__doc__R tunittestRt ImportErrort flake8.hooksRt flake8.utilRRtTestCaseRR%tmain(((s8/Users/ian7708/sandbox/flake8/flake8/tests/test_hooks.pyts    ( flake8-2.5.4/flake8/tests/test_integration.py00006440_j0000000535712477326610021053 0ustar ian770800000000000000from __future__ import with_statement import os import unittest try: from unittest import mock except ImportError: import mock # < PY33 from flake8 import engine from flake8.util import is_windows class IntegrationTestCase(unittest.TestCase): """Integration style tests to exercise different command line options.""" def this_file(self): """Return the real path of this file.""" this_file = os.path.realpath(__file__) if this_file.endswith("pyc"): this_file = this_file[:-1] return this_file def check_files(self, arglist=[], explicit_stdin=False, count=0): """Call check_files.""" if explicit_stdin: target_file = "-" else: target_file = self.this_file() argv = ['flake8'] + arglist + [target_file] with mock.patch("sys.argv", argv): style_guide = engine.get_style_guide(parse_argv=True) report = style_guide.check_files() self.assertEqual(report.total_errors, count) return style_guide, report def test_no_args(self): # assert there are no reported errors self.check_files() def _job_tester(self, jobs): # mock stdout.flush so we can count the number of jobs created with mock.patch('sys.stdout.flush') as mocked: guide, report = self.check_files(arglist=['--jobs=%s' % jobs]) if is_windows(): # The code path where guide.options.jobs gets converted to an # int is not run on windows. So, do the int conversion here. self.assertEqual(int(guide.options.jobs), jobs) # On windows, call count is always zero. self.assertEqual(mocked.call_count, 0) else: self.assertEqual(guide.options.jobs, jobs) self.assertEqual(mocked.call_count, jobs) def test_jobs(self): self._job_tester(2) self._job_tester(10) def test_stdin(self): self.count = 0 def fake_stdin(): self.count += 1 with open(self.this_file(), "r") as f: return f.read() with mock.patch("pep8.stdin_get_value", fake_stdin): guide, report = self.check_files(arglist=['--jobs=4'], explicit_stdin=True) self.assertEqual(self.count, 1) def test_stdin_fail(self): def fake_stdin(): return "notathing\n" with mock.patch("pep8.stdin_get_value", fake_stdin): # only assert needed is in check_files guide, report = self.check_files(arglist=['--jobs=4'], explicit_stdin=True, count=1) flake8-2.5.4/flake8/tests/test_integration.pyc00006440_j0000000743312641044042021200 0ustar ian770800000000000000 Tc @sddklZddkZddkZyddklZWnej oddkZnXddklZddkl Z dei fdYZ dS(i(twith_statementN(tmock(tengine(t is_windowstIntegrationTestCasecBsVeZdZdZgeddZdZdZdZdZ dZ RS( sCIntegration style tests to exercise different command line options.cCs4tiit}|ido|d }n|S(s"Return the real path of this file.tpyci(tostpathtrealpatht__file__tendswith(tselft this_file((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyR sicCs|o d}n |i}dg||g}tid|iiz"tidt}|i}WdQX|i |i |||fS(sCall check_files.t-tflake8ssys.argvt parse_argvN( R Rtpatcht__exit__t __enter__Rtget_style_guidetTruet check_filest assertEqualt total_errors(R targlisttexplicit_stdintcountt target_filetargvt style_guidetreport((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyRs  cCs|idS(N(R(R ((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyt test_no_args%scCstidii}z|~}|idd|g\}}to3|it|ii ||i|i dn*|i|ii ||i|i |WdQXdS(Nssys.stdout.flushRs --jobs=%si( RRRRRRRtinttoptionstjobst call_count(R R"t_[1]tmockedtguideR((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyt _job_tester)s& cCs|id|iddS(Nii (R'(R ((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyt test_jobs7s c std_fd}tid|iiz%iddgdt\}}WdQXiiddS(NicsOid7_tidii}z|~}|iSWdQXdS(Nitr(RtopenR RRtread(R$tf(R (s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyt fake_stdin>s,spep8.stdin_get_valueRs--jobs=4Ri(RRRRRRRR(R R-R&R((R s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyt test_stdin;s  c CsXd}tid|iiz+|iddgdtdd\}}WdQXdS(NcSsdS(Ns notathing ((((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyR-Isspep8.stdin_get_valueRs--jobs=4RRi(RRRRRR(R R-R&R((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyttest_stdin_failHs  ( t__name__t __module__t__doc__R tFalseRRR'R(R.R/(((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyRs     ( t __future__RRtunittestRt ImportErrorRRt flake8.utilRtTestCaseR(((s>/Users/ian7708/sandbox/flake8/flake8/tests/test_integration.pyts  flake8-2.5.4/flake8/tests/test_main.py00006440_j0000000056012520516042017430 0ustar ian770800000000000000from __future__ import with_statement import unittest import setuptools from flake8 import main class TestMain(unittest.TestCase): def test_issue_39_regression(self): distribution = setuptools.Distribution() cmd = main.Flake8Command(distribution) cmd.options_dict = {} cmd.run() if __name__ == '__main__': unittest.main() flake8-2.5.4/flake8/tests/test_main.pyc00006440_j0000000160312641044042017572 0ustar ian770800000000000000 "BUc@spddklZddkZddkZddklZdeifdYZedjoeindS(i(twith_statementN(tmaintTestMaincBseZdZRS(cCs2ti}ti|}h|_|idS(N(t setuptoolst DistributionRt Flake8Commandt options_dicttrun(tselft distributiontcmd((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_main.pyttest_issue_39_regression s  (t__name__t __module__R (((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_main.pyR st__main__( t __future__RtunittestRtflake8RtTestCaseRR (((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_main.pyts    flake8-2.5.4/flake8/tests/test_pyflakes.py00006440_j0000000611712641044550020332 0ustar ian770800000000000000from __future__ import with_statement import ast import unittest from collections import namedtuple from flake8._pyflakes import FlakesChecker Options = namedtuple("Options", ['builtins', 'doctests', 'include_in_doctest', 'exclude_from_doctest']) class TestFlakesChecker(unittest.TestCase): def setUp(self): self.tree = ast.parse('print("cookies")') def test_doctest_flag_enabled(self): options = Options(builtins=None, doctests=True, include_in_doctest='', exclude_from_doctest='') FlakesChecker.parse_options(options) flake_checker = FlakesChecker(self.tree, 'cookies.txt') assert flake_checker.withDoctest is True def test_doctest_flag_disabled(self): options = Options(builtins=None, doctests=False, include_in_doctest='', exclude_from_doctest='') FlakesChecker.parse_options(options) flake_checker = FlakesChecker(self.tree, 'cookies.txt') assert flake_checker.withDoctest is False def test_doctest_flag_enabled_exclude_file(self): options = Options(builtins=None, doctests=True, include_in_doctest='', exclude_from_doctest='cookies.txt,' 'hungry/cookies.txt') FlakesChecker.parse_options(options) flake_checker = FlakesChecker(self.tree, './cookies.txt') assert flake_checker.withDoctest is False def test_doctest_flag_disabled_include_file(self): options = Options(builtins=None, doctests=False, include_in_doctest='./cookies.txt,cake_yuck.txt', exclude_from_doctest='') FlakesChecker.parse_options(options) flake_checker = FlakesChecker(self.tree, './cookies.txt') assert flake_checker.withDoctest is True def test_doctest_flag_disabled_include_file_exclude_dir(self): options = Options(builtins=None, doctests=False, include_in_doctest='./cookies.txt', exclude_from_doctest='./') FlakesChecker.parse_options(options) flake_checker = FlakesChecker(self.tree, './cookies.txt') assert flake_checker.withDoctest is True def test_doctest_flag_disabled_include_dir_exclude_file(self): options = Options(builtins=None, doctests=False, include_in_doctest='./', exclude_from_doctest='./cookies.txt') FlakesChecker.parse_options(options) flake_checker = FlakesChecker(self.tree, './cookies.txt') assert flake_checker.withDoctest is False def test_doctest_flag_disabled_include_file_exclude_file_error(self): options = Options(builtins=None, doctests=False, include_in_doctest='./cookies.txt', exclude_from_doctest='./cookies.txt,cake_yuck.txt') self.assertRaises(ValueError, FlakesChecker.parse_options, options) flake8-2.5.4/flake8/tests/test_pyflakes.pyc00006440_j0000000742512641044042020474 0ustar ian770800000000000000 HVc @sddklZddkZddkZddklZddklZeddddd gZd ei fd YZ dS( i(twith_statementN(t namedtuple(t FlakesCheckertOptionstbuiltinstdocteststinclude_in_doctesttexclude_from_doctesttTestFlakesCheckercBsPeZdZdZdZdZdZdZdZdZ RS(cCstid|_dS(Nsprint("cookies")(tasttparsettree(tself((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pytsetUpsc Cs[tdddtdddd}ti|t|id}|itjptdS(NRRRtRs cookies.txt(RtNonetTrueRt parse_optionsR t withDoctesttAssertionError(R toptionst flake_checker((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyttest_doctest_flag_enableds   c Cs[tdddtdddd}ti|t|id}|itjptdS(NRRRRRs cookies.txt(RRtFalseRRR RR(R RR((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyttest_doctest_flag_disableds   c Cs[tdddtdddd}ti|t|id}|itjptdS(NRRRRRscookies.txt,hungry/cookies.txts ./cookies.txt( RRRRRR RRR(R RR((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyt&test_doctest_flag_enabled_exclude_file$s   c Cs[tdddtdddd}ti|t|id}|itjptdS(NRRRs./cookies.txt,cake_yuck.txtRRs ./cookies.txt( RRRRRR RRR(R RR((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyt'test_doctest_flag_disabled_include_file-s   c Cs[tdddtdddd}ti|t|id}|itjptdS(NRRRs ./cookies.txtRs./( RRRRRR RRR(R RR((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyt3test_doctest_flag_disabled_include_file_exclude_dir5s   c Cs[tdddtdddd}ti|t|id}|itjptdS(NRRRs./Rs ./cookies.txt(RRRRRR RR(R RR((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyt3test_doctest_flag_disabled_include_dir_exclude_file=s   c CsStdddtdddd}|itiizti|WdQXdS(NRRRs ./cookies.txtRs./cookies.txt,cake_yuck.txt( RRRt assertRaisest ValueErrort__exit__t __enter__RR(R R((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyt:test_doctest_flag_disabled_include_file_exclude_file_errorEs  ( t__name__t __module__R RRRRRRR!(((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyRs      ( t __future__RR tunittestt collectionsRtflake8._pyflakesRRtTestCaseR(((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_pyflakes.pyts    flake8-2.5.4/flake8/tests/test_reporter.py00006440_j0000000214512633612251020353 0ustar ian770800000000000000from __future__ import with_statement import errno import unittest try: from unittest import mock except ImportError: import mock # < PY33 from flake8 import reporter def ioerror_report_factory(errno_code): class IOErrorBaseQReport(reporter.BaseQReport): def _process_main(self): raise IOError(errno_code, 'Fake bad pipe exception') options = mock.MagicMock() options.jobs = 2 return IOErrorBaseQReport(options) class TestBaseQReport(unittest.TestCase): def test_does_not_raise_a_bad_pipe_ioerror(self): """Test that no EPIPE IOError exception is re-raised or leaked.""" report = ioerror_report_factory(errno.EPIPE) try: report.process_main() except IOError: self.fail('BaseQReport.process_main raised an IOError for EPIPE' ' but it should have caught this exception.') def test_raises_a_enoent_ioerror(self): """Test that an ENOENT IOError exception is re-raised.""" report = ioerror_report_factory(errno.ENOENT) self.assertRaises(IOError, report.process_main) flake8-2.5.4/flake8/tests/test_reporter.pyc00006440_j0000000421012641044042020505 0ustar ian770800000000000000 oVc @sddklZddkZddkZyddklZWnej oddkZnXddklZdZdei fdYZ dS(i(twith_statementN(tmock(treportercs>dtiffdY}ti}d|_||S(NtIOErrorBaseQReportcseZfdZRS(cstddS(NsFake bad pipe exception(tIOError(tself(t errno_code(s;/Users/ian7708/sandbox/flake8/flake8/tests/test_reporter.pyt _process_mains(t__name__t __module__R((R(s;/Users/ian7708/sandbox/flake8/flake8/tests/test_reporter.pyRsi(Rt BaseQReportRt MagicMocktjobs(RRtoptions((Rs;/Users/ian7708/sandbox/flake8/flake8/tests/test_reporter.pytioerror_report_factory s  tTestBaseQReportcBseZdZdZRS(cCsDtti}y|iWn tj o|idnXdS(s<Test that no EPIPE IOError exception is re-raised or leaked.s^BaseQReport.process_main raised an IOError for EPIPE but it should have caught this exception.N(RterrnotEPIPEt process_mainRtfail(Rtreport((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_reporter.pyt&test_does_not_raise_a_bad_pipe_ioerrors cCs&tti}|it|idS(s3Test that an ENOENT IOError exception is re-raised.N(RRtENOENTt assertRaisesRR(RR((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_reporter.pyttest_raises_a_enoent_ioerror!s(RR RR(((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_reporter.pyRs ( t __future__RRtunittestRt ImportErrortflake8RRtTestCaseR(((s;/Users/ian7708/sandbox/flake8/flake8/tests/test_reporter.pyts   flake8-2.5.4/flake8/tests/test_util.py00006440_j0000000425012633612251017465 0ustar ian770800000000000000import unittest from flake8.util import option_normalizer class TestOptionSerializer(unittest.TestCase): def test_1_is_true(self): option = option_normalizer('1') self.assertTrue(option) def test_T_is_true(self): option = option_normalizer('T') self.assertTrue(option) def test_TRUE_is_true(self): option = option_normalizer('TRUE') self.assertTrue(option, True) def test_ON_is_true(self): option = option_normalizer('ON') self.assertTrue(option) def test_t_is_true(self): option = option_normalizer('t') self.assertTrue(option) def test_true_is_true(self): option = option_normalizer('true') self.assertTrue(option) def test_on_is_true(self): option = option_normalizer('on') self.assertTrue(option) def test_0_is_false(self): option = option_normalizer('0') self.assertFalse(option) def test_F_is_false(self): option = option_normalizer('F') self.assertFalse(option) def test_FALSE_is_false(self): option = option_normalizer('FALSE') self.assertFalse(option) def test_OFF_is_false(self): option = option_normalizer('OFF') self.assertFalse(option) def test_f_is_false(self): option = option_normalizer('f') self.assertFalse(option) def test_false_is_false(self): option = option_normalizer('false') self.assertFalse(option) def test_off_is_false(self): option = option_normalizer('off') self.assertFalse(option) def test_parses_lists(self): answer = ['F401', 'F402', 'F403', 'F404'] option = option_normalizer('F401,F402,F403,F404') self.assertEqual(option, answer) option = option_normalizer('F401 ,F402 ,F403 ,F404') self.assertEqual(option, answer) option = option_normalizer('F401, F402, F403, F404') self.assertEqual(option, answer) option = option_normalizer('''\ F401, F402, F403, F404, ''') self.assertEqual(option, answer) if __name__ == '__main__': unittest.main() flake8-2.5.4/flake8/tests/test_util.pyc00006440_j0000001002512641044042017621 0ustar ian770800000000000000 oVc@sTddkZddklZdeifdYZedjoeindS(iN(toption_normalizertTestOptionSerializercBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZRS(cCstd}|i|dS(Nt1(Rt assertTrue(tselftoption((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_1_is_trues cCstd}|i|dS(NtT(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_T_is_true s cCs td}|i|tdS(NtTRUE(RRtTrue(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_TRUE_is_trues cCstd}|i|dS(NtON(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_ON_is_trues cCstd}|i|dS(Ntt(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_t_is_trues cCstd}|i|dS(Nttrue(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_true_is_trues cCstd}|i|dS(Nton(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_on_is_true s cCstd}|i|dS(Nt0(Rt assertFalse(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_0_is_false$s cCstd}|i|dS(NtF(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_F_is_false(s cCstd}|i|dS(NtFALSE(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_FALSE_is_false,s cCstd}|i|dS(NtOFF(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_OFF_is_false0s cCstd}|i|dS(Ntf(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_f_is_false4s cCstd}|i|dS(Ntfalse(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_false_is_false8s cCstd}|i|dS(Ntoff(RR(RR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_off_is_false<s cCsddddg}td}|i||td}|i||td}|i||td}|i||dS( NtF401tF402tF403tF404sF401,F402,F403,F404sF401 ,F402 ,F403 ,F404sF401, F402, F403, F404sP F401, F402, F403, F404, (Rt assertEqual(RtanswerR((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyttest_parses_lists@s    (t__name__t __module__RRR R RRRRRRRRR R"R)(((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyRs              t__main__(tunittestt flake8.utilRtTestCaseRR*tmain(((s7/Users/ian7708/sandbox/flake8/flake8/tests/test_util.pyts O flake8-2.5.4/flake8/util.py00006440_j0000000350712633612251015270 0ustar ian770800000000000000# -*- coding: utf-8 -*- import os 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_windows(): """Determine if the system is Windows.""" return os.name == 'nt' def is_using_stdin(paths): """Determine if we're running checks on stdin.""" return '-' in paths def warn_when_using_jobs(options): return (options.verbose and options.jobs and options.jobs.isdigit() and int(options.jobs) > 1) def force_disable_jobs(styleguide): return is_windows() or is_using_stdin(styleguide.paths) def option_normalizer(value): if str(value).upper() in ('1', 'T', 'TRUE', 'ON'): value = True if str(value).upper() in ('0', 'F', 'FALSE', 'OFF'): value = False if isinstance(value, str): value = [opt.strip() for opt in value.split(',') if opt.strip()] return value flake8-2.5.4/flake8/util.pyc00006440_j0000000567512641044042015437 0ustar ian770800000000000000 oVc@sddkZyddkZeiZWn`ej oTddkZdeiijo%d ei_edei _ndZnXde fdYZ dZ dZ d Zd Zd ZdS( iNtdecorator_listcCs|iS((t decorators(ts((s,/Users/ian7708/sandbox/flake8/flake8/util.pyt sccs|ipdSx|iD]u}t||d}t|tio |Vqt|to1x.|D]"}t|tio |VqdqdWqqWdS(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,/Users/ian7708/sandbox/flake8/flake8/util.pytiter_child_nodess   t OrderedSetcBseZdZdZdZRS(sList without duplicates.cCs"||jo|i|ndS(N(tappend(tselftvalue((s,/Users/ian7708/sandbox/flake8/flake8/util.pytadd$s ((t__name__t __module__t__doc__t __slots__R(((s,/Users/ian7708/sandbox/flake8/flake8/util.pyR scCs tidjS(s#Determine if the system is Windows.tnt(tosR (((s,/Users/ian7708/sandbox/flake8/flake8/util.pyt is_windows)scCs d|jS(s+Determine if we're running checks on stdin.t-((tpaths((s,/Users/ian7708/sandbox/flake8/flake8/util.pytis_using_stdin.scCs7|io-|io#|iiot|idjS(Ni(tverbosetjobstisdigittint(toptions((s,/Users/ian7708/sandbox/flake8/flake8/util.pytwarn_when_using_jobs3s$cCstp t|iS(N(RRR(t styleguide((s,/Users/ian7708/sandbox/flake8/flake8/util.pytforce_disable_jobs8scCst|id jo t}nt|id jo t}nt|toEg}|id D]$}|io||iqjqj~}n|S( Nt1tTtTRUEtONt0tFtFALSEtOFFt,(R'R(sTRUEsON(R+R,sFALSEsOFF(tstrtuppertTruetFalseRtsplittstrip(Rt_[1]topt((s,/Users/ian7708/sandbox/flake8/flake8/util.pytoption_normalizer<s  E((RRRt ImportErrort_asttClassDefRRtpropertyt FunctionDefR RRRR$R&R8(((s,/Users/ian7708/sandbox/flake8/flake8/util.pyts         flake8-2.5.4/flake8.egg-info/00007550_j0000000000012657145314015435 5ustar ian770800000000000000flake8-2.5.4/flake8.egg-info/dependency_links.txt00006440_j0000000000112657145313021502 0ustar ian770800000000000000 flake8-2.5.4/flake8.egg-info/entry_points.txt00006440_j0000000023512657145313020732 0ustar ian770800000000000000[console_scripts] flake8 = flake8.main:main [distutils.commands] flake8 = flake8.main:Flake8Command [flake8.extension] F = flake8._pyflakes:FlakesChecker flake8-2.5.4/flake8.egg-info/pbr.json00006440_j0000000005712547753760017125 0ustar ian770800000000000000{"is_release": false, "git_version": "b827629"}flake8-2.5.4/flake8.egg-info/PKG-INFO00006440_j0000004026712657145313016542 0ustar ian770800000000000000Metadata-Version: 1.1 Name: flake8 Version: 2.5.4 Summary: the modular source code checker: pep8, pyflakes and co Home-page: https://gitlab.com/pycqa/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. Frequently Asked Questions ========================== Why does flake8 pin the version of pep8? ---------------------------------------- Version 1.6 of pep8 doesn't work properly with flake8. Until pep8 releases a version that works, flake8 pins the version of pep8 so that flake8 will work as a whole. Is flake8 broken? ----------------- Flake8 combines two other projects that are significant on their own: pep8 and PyFlakes. If flake8 is doing something you don't like, it is quite likely that the problem lies in one of those other projects. You can run them separately to see if they are the cause of your difficulties. We greatly appreciate your efforts to diagnose the source of the problem before reporting bugs against flake8. 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.5.4 - 2016-02-11 ------------------ - **Bug** Missed an attribute rename during the v2.5.3 release. 2.5.3 - 2016-02-11 ------------------ - **Bug** Actually parse ``output_file`` and ``enable_extensions`` from config files 2.5.2 - 2016-01-30 ------------------ - **Bug** Parse ``output_file`` and ``enable_extensions`` from config files - **Improvement** Raise upper bound on mccabe plugin to allow for version 0.4.0 2.5.1 - 2015-12-08 ------------------ - **Bug** Properly look for ``.flake8`` in current working directory (`GitLab#103`_) - **Bug** Monkey-patch ``pep8.stdin_get_value`` to cache the actual value in stdin. This helps plugins relying on the function when run with multiprocessing. (`GitLab#105`_, `GitLab#107`_) .. _GitLab#103: https://gitlab.com/pycqa/flake8/issues/103 .. _GitLab#105: https://gitlab.com/pycqa/flake8/issues/105 .. _GitLab#107: https://gitlab.com/pycqa/flake8/issues/107 2.5.0 - 2015-10-26 ------------------ - **Improvement** Raise cap on PyFlakes for Python 3.5 support - **Improvement** Avoid deprecation warnings when loading extensions (`GitLab#59`_, `GitLab#90`_) - **Improvement** Separate logic to enable "off-by-default" extensions (`GitLab#67`_) - **Bug** Properly parse options to setuptools Flake8 command (`GitLab!41`_) - **Bug** Fix exceptions when output on stdout is truncated before Flake8 finishes writing the output (`GitLab#69`_) - **Bug** Fix error on OS X where Flake8 can no longer acquire or create new semaphores (`GitLab#74`_) .. _GitLab!41: https://gitlab.com/pycqa/flake8/merge_requests/41 .. _GitLab#59: https://gitlab.com/pycqa/flake8/issues/59 .. _GitLab#67: https://gitlab.com/pycqa/flake8/issues/67 .. _GitLab#69: https://gitlab.com/pycqa/flake8/issues/69 .. _GitLab#74: https://gitlab.com/pycqa/flake8/issues/74 .. _GitLab#90: https://gitlab.com/pycqa/flake8/issues/90 2.4.1 - 2015-05-18 ------------------ - **Bug** Do not raise a ``SystemError`` unless there were errors in the setuptools command. (`GitLab#39`_, `GitLab!23`_) - **Bug** Do not verify dependencies of extensions loaded via entry-points. - **Improvement** Blacklist versions of pep8 we know are broken .. _GitLab#39: https://gitlab.com/pycqa/flake8/issues/39 .. _GitLab!23: https://gitlab.com/pycqa/flake8/merge_requests/23 2.4.0 - 2015-03-07 ------------------ - **Bug** Print filenames when using multiprocessing and ``-q`` option. (`GitLab#31`_) - **Bug** Put upper cap on dependencies. The caps for 2.4.0 are: - ``pep8 < 1.6`` (Related to `GitLab#35`_) - ``mccabe < 0.4`` - ``pyflakes < 0.9`` See also `GitLab#32`_ - **Bug** Files excluded in a config file were not being excluded when flake8 was run from a git hook. (`GitHub#2`_) - **Improvement** Print warnings for users who are providing mutually exclusive options to flake8. (`GitLab#8`_, `GitLab!18`_) - **Feature** Allow git hook configuration to live in ``.git/config``. See the updated `VCS hooks docs`_ for more details. (`GitLab!20`_) .. _GitHub#2: https://github.com/pycqa/flake8/pull/2 .. _GitLab#8: https://gitlab.com/pycqa/flake8/issues/8 .. _GitLab#31: https://gitlab.com/pycqa/flake8/issues/31 .. _GitLab#32: https://gitlab.com/pycqa/flake8/issues/32 .. _GitLab#35: https://gitlab.com/pycqa/flake8/issues/35 .. _GitLab!18: https://gitlab.com/pycqa/flake8/merge_requests/18 .. _GitLab!20: https://gitlab.com/pycqa/flake8/merge_requests/20 .. _VCS hooks docs: https://flake8.readthedocs.org/en/latest/vcs.html 2.3.0 - 2015-01-04 ------------------ - **Feature**: Add ``--output-file`` option to specify a file to write to instead of ``stdout``. - **Bug** Fix interleaving of output while using multiprocessing (`GitLab#17`_) .. _GitLab#17: https://gitlab.com/pycqa/flake8/issues/17 2.2.5 - 2014-10-19 ------------------ - Flush standard out when using multiprocessing - Make the check for "# flake8: noqa" more strict 2.2.4 - 2014-10-09 ------------------ - Fix bugs triggered by turning multiprocessing on by default (again) Multiprocessing is forcibly disabled in the following cases: - Passing something in via stdin - Analyzing a diff - Using windows - Fix --install-hook when there are no config files present for pep8 or flake8. - Fix how the setuptools command parses excludes in config files - Fix how the git hook determines which files to analyze (Thanks Chris Buccella!) 2.2.3 - 2014-08-25 ------------------ - Actually turn multiprocessing on by default 2.2.2 - 2014-07-04 ------------------ - Re-enable multiprocessing by default while fixing the issue Windows users were seeing. 2.2.1 - 2014-06-30 ------------------ - Turn off multiple jobs by default. To enable automatic use of all CPUs, use ``--jobs=auto``. Fixes #155 and #154. 2.2.0 - 2014-06-22 ------------------ - New option ``doctests`` to run Pyflakes checks on doctests too - New option ``jobs`` to launch multiple jobs in parallel - Turn on using multiple jobs by default using the CPU count - Add support for ``python -m flake8`` on Python 2.7 and Python 3 - Fix Git and Mercurial hooks: issues #88, #133, #148 and #149 - Fix crashes with Python 3.4 by upgrading dependencies - Fix traceback when running tests with Python 2.6 - Fix the setuptools command ``python setup.py flake8`` to read the project configuration 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 if 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.5.4/flake8.egg-info/requires.txt00006440_j0000000013412657145313020032 0ustar ian770800000000000000pyflakes >= 0.8.1, < 1.1 pep8 >= 1.5.7, != 1.6.0, != 1.6.1, != 1.6.2 mccabe >= 0.2.1, < 0.5 flake8-2.5.4/flake8.egg-info/SOURCES.txt00006440_j0000000377112657145314017331 0ustar ian770800000000000000CHANGES.rst CONTRIBUTORS.txt LICENSE MANIFEST.in README.rst setup.cfg setup.py flake8/__init__.py flake8/__init__.pyc flake8/__main__.py flake8/_pyflakes.py flake8/_pyflakes.pyc flake8/callbacks.py flake8/callbacks.pyc flake8/compat.py flake8/compat.pyc flake8/engine.py flake8/engine.pyc flake8/hooks.py flake8/hooks.pyc flake8/main.py flake8/main.pyc flake8/reporter.py flake8/reporter.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/pbr.json flake8.egg-info/requires.txt flake8.egg-info/top_level.txt flake8/__pycache__/__init__.cpython-34.pyc flake8/__pycache__/_pyflakes.cpython-34.pyc flake8/__pycache__/callbacks.cpython-34.pyc flake8/__pycache__/compat.cpython-34.pyc flake8/__pycache__/engine.cpython-34.pyc flake8/__pycache__/hooks.cpython-34.pyc flake8/__pycache__/main.cpython-34.pyc flake8/__pycache__/reporter.cpython-34.pyc flake8/__pycache__/util.cpython-34.pyc flake8/tests/__init__.py flake8/tests/__init__.pyc flake8/tests/_test_warnings.py flake8/tests/_test_warnings.pyc flake8/tests/test_engine.py flake8/tests/test_engine.pyc flake8/tests/test_git_hook.pyc flake8/tests/test_hooks.py flake8/tests/test_hooks.pyc flake8/tests/test_integration.py flake8/tests/test_integration.pyc flake8/tests/test_main.py flake8/tests/test_main.pyc flake8/tests/test_pyflakes.py flake8/tests/test_pyflakes.pyc flake8/tests/test_reporter.py flake8/tests/test_reporter.pyc flake8/tests/test_util.py flake8/tests/test_util.pyc flake8/tests/__pycache__/__init__.cpython-34.pyc flake8/tests/__pycache__/_test_warnings.cpython-34.pyc flake8/tests/__pycache__/test_engine.cpython-34.pyc flake8/tests/__pycache__/test_hooks.cpython-34.pyc flake8/tests/__pycache__/test_integration.cpython-34.pyc flake8/tests/__pycache__/test_main.cpython-34.pyc flake8/tests/__pycache__/test_pyflakes.cpython-34.pyc flake8/tests/__pycache__/test_reporter.cpython-34.pyc flake8/tests/__pycache__/test_util.cpython-34.pycflake8-2.5.4/flake8.egg-info/top_level.txt00006440_j0000000000712657145313020163 0ustar ian770800000000000000flake8 flake8-2.5.4/LICENSE00006440_j0000000222412415552077013576 0ustar ian770800000000000000== 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.5.4/MANIFEST.in00006440_j0000000012212415552077014322 0ustar ian770800000000000000include *.rst include CONTRIBUTORS.txt include LICENSE recursive-include flake8 * flake8-2.5.4/PKG-INFO00006440_j0000004026712657145314013677 0ustar ian770800000000000000Metadata-Version: 1.1 Name: flake8 Version: 2.5.4 Summary: the modular source code checker: pep8, pyflakes and co Home-page: https://gitlab.com/pycqa/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. Frequently Asked Questions ========================== Why does flake8 pin the version of pep8? ---------------------------------------- Version 1.6 of pep8 doesn't work properly with flake8. Until pep8 releases a version that works, flake8 pins the version of pep8 so that flake8 will work as a whole. Is flake8 broken? ----------------- Flake8 combines two other projects that are significant on their own: pep8 and PyFlakes. If flake8 is doing something you don't like, it is quite likely that the problem lies in one of those other projects. You can run them separately to see if they are the cause of your difficulties. We greatly appreciate your efforts to diagnose the source of the problem before reporting bugs against flake8. 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.5.4 - 2016-02-11 ------------------ - **Bug** Missed an attribute rename during the v2.5.3 release. 2.5.3 - 2016-02-11 ------------------ - **Bug** Actually parse ``output_file`` and ``enable_extensions`` from config files 2.5.2 - 2016-01-30 ------------------ - **Bug** Parse ``output_file`` and ``enable_extensions`` from config files - **Improvement** Raise upper bound on mccabe plugin to allow for version 0.4.0 2.5.1 - 2015-12-08 ------------------ - **Bug** Properly look for ``.flake8`` in current working directory (`GitLab#103`_) - **Bug** Monkey-patch ``pep8.stdin_get_value`` to cache the actual value in stdin. This helps plugins relying on the function when run with multiprocessing. (`GitLab#105`_, `GitLab#107`_) .. _GitLab#103: https://gitlab.com/pycqa/flake8/issues/103 .. _GitLab#105: https://gitlab.com/pycqa/flake8/issues/105 .. _GitLab#107: https://gitlab.com/pycqa/flake8/issues/107 2.5.0 - 2015-10-26 ------------------ - **Improvement** Raise cap on PyFlakes for Python 3.5 support - **Improvement** Avoid deprecation warnings when loading extensions (`GitLab#59`_, `GitLab#90`_) - **Improvement** Separate logic to enable "off-by-default" extensions (`GitLab#67`_) - **Bug** Properly parse options to setuptools Flake8 command (`GitLab!41`_) - **Bug** Fix exceptions when output on stdout is truncated before Flake8 finishes writing the output (`GitLab#69`_) - **Bug** Fix error on OS X where Flake8 can no longer acquire or create new semaphores (`GitLab#74`_) .. _GitLab!41: https://gitlab.com/pycqa/flake8/merge_requests/41 .. _GitLab#59: https://gitlab.com/pycqa/flake8/issues/59 .. _GitLab#67: https://gitlab.com/pycqa/flake8/issues/67 .. _GitLab#69: https://gitlab.com/pycqa/flake8/issues/69 .. _GitLab#74: https://gitlab.com/pycqa/flake8/issues/74 .. _GitLab#90: https://gitlab.com/pycqa/flake8/issues/90 2.4.1 - 2015-05-18 ------------------ - **Bug** Do not raise a ``SystemError`` unless there were errors in the setuptools command. (`GitLab#39`_, `GitLab!23`_) - **Bug** Do not verify dependencies of extensions loaded via entry-points. - **Improvement** Blacklist versions of pep8 we know are broken .. _GitLab#39: https://gitlab.com/pycqa/flake8/issues/39 .. _GitLab!23: https://gitlab.com/pycqa/flake8/merge_requests/23 2.4.0 - 2015-03-07 ------------------ - **Bug** Print filenames when using multiprocessing and ``-q`` option. (`GitLab#31`_) - **Bug** Put upper cap on dependencies. The caps for 2.4.0 are: - ``pep8 < 1.6`` (Related to `GitLab#35`_) - ``mccabe < 0.4`` - ``pyflakes < 0.9`` See also `GitLab#32`_ - **Bug** Files excluded in a config file were not being excluded when flake8 was run from a git hook. (`GitHub#2`_) - **Improvement** Print warnings for users who are providing mutually exclusive options to flake8. (`GitLab#8`_, `GitLab!18`_) - **Feature** Allow git hook configuration to live in ``.git/config``. See the updated `VCS hooks docs`_ for more details. (`GitLab!20`_) .. _GitHub#2: https://github.com/pycqa/flake8/pull/2 .. _GitLab#8: https://gitlab.com/pycqa/flake8/issues/8 .. _GitLab#31: https://gitlab.com/pycqa/flake8/issues/31 .. _GitLab#32: https://gitlab.com/pycqa/flake8/issues/32 .. _GitLab#35: https://gitlab.com/pycqa/flake8/issues/35 .. _GitLab!18: https://gitlab.com/pycqa/flake8/merge_requests/18 .. _GitLab!20: https://gitlab.com/pycqa/flake8/merge_requests/20 .. _VCS hooks docs: https://flake8.readthedocs.org/en/latest/vcs.html 2.3.0 - 2015-01-04 ------------------ - **Feature**: Add ``--output-file`` option to specify a file to write to instead of ``stdout``. - **Bug** Fix interleaving of output while using multiprocessing (`GitLab#17`_) .. _GitLab#17: https://gitlab.com/pycqa/flake8/issues/17 2.2.5 - 2014-10-19 ------------------ - Flush standard out when using multiprocessing - Make the check for "# flake8: noqa" more strict 2.2.4 - 2014-10-09 ------------------ - Fix bugs triggered by turning multiprocessing on by default (again) Multiprocessing is forcibly disabled in the following cases: - Passing something in via stdin - Analyzing a diff - Using windows - Fix --install-hook when there are no config files present for pep8 or flake8. - Fix how the setuptools command parses excludes in config files - Fix how the git hook determines which files to analyze (Thanks Chris Buccella!) 2.2.3 - 2014-08-25 ------------------ - Actually turn multiprocessing on by default 2.2.2 - 2014-07-04 ------------------ - Re-enable multiprocessing by default while fixing the issue Windows users were seeing. 2.2.1 - 2014-06-30 ------------------ - Turn off multiple jobs by default. To enable automatic use of all CPUs, use ``--jobs=auto``. Fixes #155 and #154. 2.2.0 - 2014-06-22 ------------------ - New option ``doctests`` to run Pyflakes checks on doctests too - New option ``jobs`` to launch multiple jobs in parallel - Turn on using multiple jobs by default using the CPU count - Add support for ``python -m flake8`` on Python 2.7 and Python 3 - Fix Git and Mercurial hooks: issues #88, #133, #148 and #149 - Fix crashes with Python 3.4 by upgrading dependencies - Fix traceback when running tests with Python 2.6 - Fix the setuptools command ``python setup.py flake8`` to read the project configuration 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 if 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.5.4/README.rst00006440_j0000000614212633612251014254 0ustar ian770800000000000000====== 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. Frequently Asked Questions ========================== Why does flake8 pin the version of pep8? ---------------------------------------- Version 1.6 of pep8 doesn't work properly with flake8. Until pep8 releases a version that works, flake8 pins the version of pep8 so that flake8 will work as a whole. Is flake8 broken? ----------------- Flake8 combines two other projects that are significant on their own: pep8 and PyFlakes. If flake8 is doing something you don't like, it is quite likely that the problem lies in one of those other projects. You can run them separately to see if they are the cause of your difficulties. We greatly appreciate your efforts to diagnose the source of the problem before reporting bugs against flake8. 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.5.4/setup.cfg00006440_j0000000012212657145314014405 0ustar ian770800000000000000[wheel] universal = 1 [egg_info] tag_svn_revision = 0 tag_date = 0 tag_build = flake8-2.5.4/setup.py00006440_j0000000421012656732221014276 0ustar ian770800000000000000# -*- coding: utf-8 -*- from __future__ import with_statement from setuptools import setup try: # Work around a traceback with Nose on Python 2.6 # http://bugs.python.org/issue15881#msg170215 __import__('multiprocessing') except ImportError: pass try: # Use https://docs.python.org/3/library/unittest.mock.html from unittest import mock except ImportError: # < Python 3.3 mock = None tests_require = ['nose'] if mock is None: tests_require += ['mock'] 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="https://gitlab.com/pycqa/flake8", packages=["flake8", "flake8.tests"], install_requires=[ "pyflakes >= 0.8.1, < 1.1", "pep8 >= 1.5.7, != 1.6.0, != 1.6.1, != 1.6.2", "mccabe >= 0.2.1, < 0.5", ], 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=tests_require, test_suite='nose.collector', )