[PATCH 2 of 4] test-pyflakes: do not parse file that is unlikely a Python script

Matt Mackall mpm at selenic.com
Fri May 2 00:21:34 CDT 2014


On Fri, 2014-05-02 at 13:28 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1398743365 -32400
> #      Tue Apr 29 12:49:25 2014 +0900
> # Branch stable
> # Node ID 9428e9853f59843545eac04caf8463ebf1d5efa2
> # Parent  ab91be7bb1a363e7ff320bece1e238dcf8d634e1
> test-pyflakes: do not parse file that is unlikely a Python script
> 
> This eliminates false alarm triggered by parsing shell scripts or template
> map files.  For example, "pyflakes mercurial/templates/atom/map" reports
> many "undefined name"s.
> 
> diff --git a/tests/test-check-pyflakes.t b/tests/test-check-pyflakes.t
> --- a/tests/test-check-pyflakes.t
> +++ b/tests/test-check-pyflakes.t
> @@ -2,10 +2,9 @@
>  
>    $ cd "`dirname "$TESTDIR"`"
>  
> -run pyflakes on all tracked files ending in .py or without a file ending
> -(skipping binary file random-seed)
> +run pyflakes on all tracked python scripts
>  
> -  $ hg locate -r. -I '**.py' -I 'relre:^[^.]*$' -X 'relre:/random_seed$' \
> +  $ hg locate -r. -I '**.py' -I 'set: "relre:^[^.]*$" and grep("^#!.*python")' \

Great idea, but we can simplify it further (and make it more inclusive)
thusly:

     $ hg locate 'set:**.py or grep("^!#.*python")'

- we want to include tracked but uncommitted files
- we want to include files with names like *.cgi
- we can use fileset operators rather than -I and -X

I've queued a version that does this locally.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list