Introduce a @deprecated decorator.

Review Request #1725 - Created Feb. 6, 2015 and submitted

Information
John Sirois
pants
jsirois/deprecated/decorator
1048
1772, 1773
e82a75e...
Reviewers
pants-reviews
dturner-tw, lahosken, mateor, patricklaw, zundel
Deprecations will be an ongoing part of moving pants forward. This
decorator standardizes denotation of deprecated functions by requiring a
future version of removal be noted and by routing and displaying these
warnings in a consistent way.

Ported AbstractTarget.is_* deprecations to this new system as an
example.

 src/python/pants/base/BUILD                     |   9 ++++
 src/python/pants/base/deprecated.py             |  84 +++++++++++++++++++++++++++++++++++
 src/python/pants/base/target.py                 |  32 +++++---------
 src/python/pants/bin/pants_exe.py               |  10 +++++
 tests/python/pants_test/base/BUILD              |  10 +++++
 tests/python/pants_test/base/test_deprecated.py | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 241 insertions(+), 22 deletions(-)

Look and feel (note 1 warning instead of N and extra detail of file, line
no and line snippet):

$ pants.dev compile examples/src/java/::
...
02:56:25 00:00   [compile]
02:56:25 00:00     [compile]
02:56:25 00:00     [jvm]
02:56:25 00:00       [jvm-compilers] WARN] /home/jsirois/dev-jsirois-pants3/src/python/pants/backend/jvm/tasks/jvm_compile/java/java_compile.py:151: DeprecationWarning: 
pants.base.target.is_apt is deprecated and will be removed in version 0.0.30:
Do not use this method, use an isinstance check on AnnotationProcessor.
  if target.is_apt and target.processors:

...

And then the new test:

$ PANTS_PY_COVERAGE=modules:pants.base.deprecated PANTS_DEV=1 ./pants test tests/python/pants_test/base:deprecated
...
02:48:31 00:00   [test]
02:48:31 00:00     [run_prep_command]
02:48:31 00:00     [test]
02:48:31 00:00     [pytest]
02:48:31 00:00       [run]
                     ============== test session starts ===============
                     platform linux2 -- Python 2.7.8 -- py-1.4.26 -- pytest-2.6.4
                     plugins: timeout
                     collected 9 items 

                     tests/python/pants_test/base/test_deprecated.py .........

                     ============ 9 passed in 0.13 seconds ============
                     Name                               Stmts   Miss Branch BrMiss  Cover
                     --------------------------------------------------------------------
                     src/python/pants/base/deprecated      32      0      8      0   100%

02:48:32 00:01     [junit]
02:48:32 00:01     [specs]
               SUCCESS

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

Issues

  • 0
  • 1
  • 0
  • 1
Description From Last Updated
John Sirois
John Sirois
Eric Ayers
Patrick Lawson
Larry Hosken
Mateo Rodriguez
John Sirois
John Sirois
Eric Ayers
Mateo Rodriguez
John Sirois
John Sirois
John Sirois
Mateo Rodriguez
John Sirois
Eric Ayers
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)

Loading...