Handle warnings in BUILD file context.

Review Request #2198 - Created May 10, 2015 and submitted

Information
John Sirois
pants
jsirois/build_file_parser/handle_warnings
1174, 1521
a35b515...
Reviewers
pants-reviews
dturner-tw, zundel
Previously, deprecation warnings encountered parsing BUILD files did not
include BUILD file context making it harder to track down deprecated
constructs than it had to be.

 src/python/pants/base/build_file_parser.py | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

There are actually 2 fixes here.

One added a missing newline. I'm not sure how this worked before, but for a standard BUILD file SyntaxError:
Before:

$ PANTS_DEV=1 ./pants list src/python/pants/java:
...
Exception message: Error parsing FilesystemBuildFile(/home/jsirois/dev/3rdparty/jsirois-pants4/src/python/pants/java/BUILD):
    9:     '3rdparty/python/twitter/commons:twitter.common.collections',   10:     'src/python/pants/base:build_environment',   11:     'src/python/pants/java/distribution:distribution',*  12:     'src/python/pants/util:contextutil',}                                               ^ SyntaxError: invalid syntax (BUILD, line 12)

   13:     'src/python/pants/util:dirutil',   14:     'src/python/pants/util:meta',   15:   ]   16: )
 Loading addresses from 'src/python/pants/java' failed.

After:

$ PANTS_DEV=1 ./pants list src/python/pants/java:
...
Exception message: While parsing FilesystemBuildFile(/home/jsirois/dev/3rdparty/jsirois-pants4/src/python/pants/java/BUILD):
    9:     '3rdparty/python/twitter/commons:twitter.common.collections',
   10:     'src/python/pants/base:build_environment',
   11:     'src/python/pants/java/distribution:distribution',
*  12:     'src/python/pants/util:contextutil',}
                                               ^ SyntaxError: invalid syntax (BUILD, line 12)

   13:     'src/python/pants/util:dirutil',
   14:     'src/python/pants/util:meta',
   15:   ]
   16: )

 Loading addresses from 'src/python/pants/java' failed.

And the new handling looks like so when encountering deprecated constructs in BUILD parsing:
Before:

$ PANTS_DEV=1 ./pants list src::
*** Running pants in dev mode from /home/jsirois/dev/3rdparty/jsirois-pants4/src/python/pants/bin/pants_exe.py ***
WARN] <string>:6: DeprecationWarning: 
pants.backend.core.wrapped_globs.__sub__ is deprecated and will be removed in version 0.0.35:
Instead of glob arithmetic, use glob(..., exclude=[...])

INFO] Detected git repository at /home/jsirois/dev/3rdparty/jsirois-pants4 on branch jsirois/build_file_parser/handle_warnings
src/python/pants/java/distribution:distribution
src/python/pants/docs:export
...

After:

$ PANTS_DEV=1 ./pants list src::
*** Running pants in dev mode from /home/jsirois/dev/3rdparty/jsirois-pants4/src/python/pants/bin/pants_exe.py ***
WARN] While parsing FilesystemBuildFile(/home/jsirois/dev/3rdparty/jsirois-pants4/src/python/pants/option/BUILD):
    3: 
    4: python_library(
    5:   name = 'option',
*   6:   sources = globs('*.py') - ['migrate_config.py'],
        DeprecationWarning: 
pants.backend.core.wrapped_globs.__sub__ is deprecated and will be removed in version 0.0.35:
Instead of glob arithmetic, use glob(..., exclude=[...])

    7:   dependencies = [
    8:     '3rdparty/python/twitter/commons:twitter.common.collections',
    9:     'src/python/pants/base:build_environment',
   10:     'src/python/pants/base:config',

INFO] Detected git repository at /home/jsirois/dev/3rdparty/jsirois-pants4 on branch jsirois/build_file_parser/handle_warnings
src/python/pants/java/distribution:distribution
src/python/pants/docs:export
...

CI went green here:
https://travis-ci.org/pantsbuild/pants/builds/62015920

John Sirois
Eric Ayers
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)

Loading...