Warn when deprecated options are passed to commands and improve their docs.

Review Request #14623 — Created Sept. 25, 2025 and updated

Information

RBTools
release-5.x

Reviewers

We currently allow for rbt options to be marked as deprecated, and we'll
display deprecation info in the documentation and help text for the option.
But we weren’t emitting any warnings when users actually passed them on
the command line. This change allows rbt to emit a deprecation warning
when a deprecated option is used.

This change also allows setting a replacement option and the version in
which the option will be removed. Our sphinx documentation building
functions and help text building logic have been updated to include these.

I decided to move our RBTools-specific option attributes out of
Option.attrs and made them direct attributes on the Option class
instead. This keeps a clearer separation from the argparse arguments
and lets us keep this information around after the Option is added to
the parser (previously we would strip all of our custom attributes
before adding an option to the parser). We also get easy typing on
these attributes now.

We also recently marked rbt login's --enable-logging as deprecated, and
this change defines its replacement (--debug) and removal version (6.0).

  • Tested rbt login -l saw the deprecation warning
  • Tested rbt login with options other than -l, saw no warnings
  • Ran unit tests.
  • Built docs and looked at options that have one or more of the custom
    RBTools attributes (config key, extended help, added in and the various
    deprecation related attributes).
Summary ID
Warn when deprecated options are passed to commands and improve their docs.
We currently allow for `rbt` options to be marked as deprecated, and we'll display deprecation info in the documentation and help text for the option. But we weren’t emitting any warnings when users actually passed them on the command line. This change allows `rbt` to emit a deprecation warning when a deprecated option is used. This change also allows setting a replacement option and the version in which the option will be removed. Our sphinx documentation building functions and help text building logic have been updated to include these. I decided to move our RBTools-specific option attributes out of `Option.attrs` and made them direct attributes on the `Option` class instead. This keeps a clearer separation from the `argparse` arguments and lets us keep this information around after the Option is added to the parser (previously we would strip all of our custom attributes before adding an option to the parser). We also get easy typing on these attributes now. We also recently marked `rbt login'`s `--enable-logging` as deprecated, and this change defines its replacement (`--debug`) and removal version (6.0).
71e1b5c3cc65d809f7da5e8de88afcf8562c5b48
Description From Last Updated

Can we add a blank line above this?

daviddavid

This should come from collections.abc instead of typing

daviddavid

Can we use Mapping[...] instead of dict[...] here?

daviddavid

This might be from a different change, but this should be 5.4, no?

daviddavid

This should be docutils.nodes.paragraph.

chipx86chipx86

The ] should be on the next line.

chipx86chipx86

) should be on the next line for a multi-line string.

chipx86chipx86

Do we have a local logger we can use?

chipx86chipx86

Will this work? all_options += item.option_list Same in other code paths doing this.

chipx86chipx86

This can be combined to one statement now.

chipx86chipx86

Can you make this a multi-line string with the strings on their own lines?

chipx86chipx86
david
  1. 
      
  2. rbtools/commands/base/commands.py (Diff revision 1)
     
     
     
    Show all issues

    Can we add a blank line above this?

  3. rbtools/commands/base/options.py (Diff revision 1)
     
     
    Show all issues

    Can we use Mapping[...] instead of dict[...] here?

  4. 
      
maubin
david
  1. 
      
  2. rbtools/commands/base/options.py (Diff revisions 1 - 2)
     
     
    Show all issues

    This should come from collections.abc instead of typing

  3. 
      
maubin
david
  1. Ship It!
  2. 
      
maubin
david
  1. 
      
  2. rbtools/commands/login.py (Diff revision 3)
     
     
    Show all issues

    This might be from a different change, but this should be 5.4, no?

    1. Yeah it should be, this gets fixed in a later change in my stack.

  3. 
      
david
  1. Ship It!
  2. 
      
chipx86
  1. Very nice improvements. I have a few small stylistic tweaks to suggest.

  2. docs/rbtools/_ext/rbt_commands.py (Diff revision 4)
     
     
    Show all issues

    This should be docutils.nodes.paragraph.

  3. rbtools/commands/base/commands.py (Diff revision 4)
     
     
    Show all issues

    The ] should be on the next line.

  4. rbtools/commands/base/commands.py (Diff revision 4)
     
     
    Show all issues

    ) should be on the next line for a multi-line string.

  5. rbtools/commands/base/commands.py (Diff revision 4)
     
     
    Show all issues

    Do we have a local logger we can use?

    1. We use the root logger everywhere else in this file, and we do some setup for it in BaseCommand._init_logging().

      On a sort of side note I do see that we have self.log = logging.getLogger('rb.%s' % self.name) in the init method for BaseCommand, but we don't use that logger anywhere in the RBTools codebase. I don't really wanna touch that in this change though.

  6. rbtools/commands/base/commands.py (Diff revision 4)
     
     
     
    Show all issues

    Will this work?

    all_options += item.option_list
    

    Same in other code paths doing this.

  7. rbtools/commands/base/options.py (Diff revision 4)
     
     
     
     
     
    Show all issues

    This can be combined to one statement now.

  8. rbtools/commands/base/options.py (Diff revision 4)
     
     
     
    Show all issues

    Can you make this a multi-line string with the strings on their own lines?

  9. 
      
maubin
Review request changed
Commits:
Summary ID
Warn when deprecated options are passed to commands and improve their docs.
We currently allow for `rbt` options to be marked as deprecated, and we'll display deprecation info in the documentation and help text for the option. But we weren’t emitting any warnings when users actually passed them on the command line. This change allows `rbt` to emit a deprecation warning when a deprecated option is used. This change also allows setting a replacement option and the version in which the option will be removed. Our sphinx documentation building functions and help text building logic have been updated to include these. I decided to move our RBTools-specific option attributes out of `Option.attrs` and made them direct attributes on the `Option` class instead. This keeps a clearer separation from the `argparse` arguments and lets us keep this information around after the Option is added to the parser (previously we would strip all of our custom attributes before adding an option to the parser). We also get easy typing on these attributes now. We also recently marked `rbt login'`s `--enable-logging` as deprecated, and this change defines its replacement (`--debug`) and removal version (6.0).
ba2deda4598c0829cb6c26618cdfa952949257d2
Warn when deprecated options are passed to commands and improve their docs.
We currently allow for `rbt` options to be marked as deprecated, and we'll display deprecation info in the documentation and help text for the option. But we weren’t emitting any warnings when users actually passed them on the command line. This change allows `rbt` to emit a deprecation warning when a deprecated option is used. This change also allows setting a replacement option and the version in which the option will be removed. Our sphinx documentation building functions and help text building logic have been updated to include these. I decided to move our RBTools-specific option attributes out of `Option.attrs` and made them direct attributes on the `Option` class instead. This keeps a clearer separation from the `argparse` arguments and lets us keep this information around after the Option is added to the parser (previously we would strip all of our custom attributes before adding an option to the parser). We also get easy typing on these attributes now. We also recently marked `rbt login'`s `--enable-logging` as deprecated, and this change defines its replacement (`--debug`) and removal version (6.0).
71e1b5c3cc65d809f7da5e8de88afcf8562c5b48

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
david
  1. Ship It!
  2.