[PATCH] tests: simplify and document the sorting of pyflake messages

Augie Fackler raf at durin42.com
Mon Jun 24 14:48:08 CDT 2013


On Sat, Jun 15, 2013 at 12:07:15AM +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe at besonet.ch>
> # Date 1371247580 -7200
> # Node ID 7a35b0923e5f76d96f8e789071adf81e4862301f
> # Parent  f235457a184b6003495f1a5b6c1003590186f1ab
> tests: simplify and document the sorting of pyflake messages
>
> The pyflake messages are simply ordered by message type, path and line no.
> The other details are not used for sorting.
>
> The previous ordering looks complicated and illogically.
> It was the following order ('\3:\5:\4:\1:\2:' + line):
>   message (\3 and \5)
>   var name (\4)
>   path (\1)
>   line no (\2)
>   line reference
> Ordering by var name before path looks illogically for me.
>
> diff -r f235457a184b -r 7a35b0923e5f tests/filterpyflakes.py
> --- a/tests/filterpyflakes.py	Sam Jun 15 00:04:51 2013 +0200
> +++ b/tests/filterpyflakes.py	Sam Jun 15 00:06:20 2013 +0200
> @@ -5,15 +5,12 @@
>  import sys, re, os
>
>  def makekey(message):
> +    "order by: message type, path/file, lineno"
>      # "path/file:line: message"

is this comment describing the input format?

> -    match = re.search(r"(line \d+)", message)
> -    line = ''
> -    if match:
> -        line = match.group(0)
> -        message = re.sub(r"(line \d+)", '', message)
> -    return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
> -                  r'\3:\5:\4:\1:\2:' + line,
> -                  message)
> +    m = message.split(':', 2)
> +    msg = re.sub("'.*'", "", re.sub(r"\([^\)]*\)", "", m[2]))
> +        # dropped var name and bracket content from msg
> +    return (msg, m[0], m[1])
>

This code (both old and new) is complex enough that I'd like to see
some simple doctests added to the docstring to make reviewing and
maintaining it more straightforward. Can I persuade you to follow up
with that?

>
>  lines = []
>  for line in sys.stdin:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list