Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A deprecated option past its removal version should fail eagerly #7335

stuhood opened this issue Mar 7, 2019 · 2 comments


None yet
2 participants
Copy link

commented Mar 7, 2019

Currently (as demonstrated in #7332 and #7325), the removal_version in options registration is not triggering an eager failure once the version has been bumped.

I believe that the register(..) call itself used to fail immediately when given a version in the past. Assuming that we want that behaviour, we should restore it.


This comment has been minimized.

Copy link

commented Mar 8, 2019

This would be a really useful fix and probably turn up some bugs we haven't noticed yet.


This comment has been minimized.

Copy link

commented Apr 23, 2019

To give a little closer view of how this might be solved:

  1. Start by reading the pants task developer's guide to understand how options are registered.
  2. Continue by reading and -- take note of the _check_deprecated() method, which validates that the pants version is less than the declared deprecation version for the option:
    def _check_deprecated(self, dest, kwargs):
    """Checks option for deprecation and issues a warning/error if necessary."""
    removal_version = kwargs.get('removal_version', None)
    if removal_version is not None:
    deprecated_entity_description="option '{}' in {}".format(dest, self._scope_str()),
    deprecation_start_version=kwargs.get('deprecation_start_version', None),
    hint=kwargs.get('removal_hint', None),
    stacklevel=9999) # Out of range stacklevel to suppress printing src line.

    Note that deprecation checking methods come from
  3. In, ensure the _check_deprecated() method is called "eagerly" -- meaning, within the register() method invocation, not when the option is accessed. Note that there's a lot of indirection that goes into a register() call -- you'll have to think about which level of abstraction to edit. This is the fun part!
  4. Add a unit test in, likely by adding an option with a deprecated version, kind of like here:
    # Test deprecated options with a scope

    However, we'd want to make sure that register() call (wrapped with a self.assertRaisesWithMessage(...) contextmanager) is done in its own test method, instead of that global register method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.