• 
      
    Fish Trophy

    david got a fish trophy!

    Fish Trophy

    Add rich to RBTools and replace old modules.

    Review Request #15151 — Created July 3, 2026 and submitted

    Information

    RBTools
    master

    Reviewers

    This change adds the rich library as a dependency, and creates the
    basic framework for rich output. This is based on a combination of
    Christian and my previous attempts at this work.

    This creates a new RBToolsConsole which wraps two rich Console objects
    for stdout and stderr. This also includes a few helpers for multi-step
    operations, some basic status levels, progress, spinners, and table
    output. This console is first created in a command's __init__, but
    will get recreated after we parse command-line options in order to
    properly support the new --color=[auto,always,never] option.

    When commands are running in JSON output mode, a handler is pushed onto
    the console that suppresses output. This allows commands to do what
    they've always done: unconditionally write to both stdout/stderr and the
    json output object, and whichever one is expected to run will work. The
    existing output wrappers have also been updated to write through the
    console object, so that can take advantage of the same suppression
    method.

    All uses of the old colorama, tqdm, and texttable libraries have
    been replaced with the new rich output, but I've held off on other
    output prettification for a separate change.

    • Ran unit tests.
    • Tested the various values of the --color option, the COLOR_MODE
      config key, and the NO_COLOR and FORCE_COLOR environment variables.
    • Tested rich output for the info, install, post, and status
      commands.
    Summary ID
    Add rich to RBTools and replace old modules.
    This change adds the `rich` library as a dependency, and creates the basic framework for rich output. This is based on a combination of Christian and my previous attempts at this work. This creates a new RBToolsConsole which wraps two rich `Console` objects for stdout and stderr. This also includes a few helpers for multi-step operations, some basic status levels, progress, spinners, and table output. This console is first created in a command's `__init__`, but will get recreated after we parse command-line options in order to properly support the new `--color=[auto,always,never]` option. When commands are running in JSON output mode, a handler is pushed onto the console that suppresses output. This allows commands to do what they've always done: unconditionally write to both stdout/stderr and the json output object, and whichever one is expected to run will work. The existing output wrappers have also been updated to write through the console object, so that can take advantage of the same suppression method. All uses of the old `colorama`, `tqdm`, and `texttable` libraries have been replaced with the new rich output, but I've held off on other output prettification for a separate change. Testing Done: - Ran unit tests. - Tested the various values of the `--color` option, the `COLOR_MODE` config key, and the `NO_COLOR` and `FORCE_COLOR` environment variables. - Tested rich output for the `info`, `install`, `post`, and `status` commands.
    kmrpxswxxprsrnyspyktlqwrrvwoxzuw
    Description From Last Updated

    Can you add documentation for the COLOR_MODE config key in docs/rbtools/rbt/configuration/users.rst.

    maubin maubin

    'rich.table.Table' imported but unused Column: 1 Error code: F401

    reviewbot reviewbot

    'collections.abc.Sequence' imported but unused Column: 5 Error code: F401

    reviewbot reviewbot

    The return statements make this a bit wonky to reason about. The code kind of backs this up, because we're …

    chipx86 chipx86

    This can be an if/else.

    chipx86 chipx86

    Can we use if config := self.config so we don't have to re-get the attribute?

    chipx86 chipx86

    We fetch these attributes twice. Let's pull them out.

    chipx86 chipx86

    The placement of the parents makes this read kind of funky.

    chipx86 chipx86

    We're accessing self.options.debug several times. Let's pull these out.

    chipx86 chipx86

    We can now do if output_stream := self.output_stream: here.

    chipx86 chipx86

    These can start on the Table( line, or could end with a ) on its own line.

    chipx86 chipx86

    Same here.

    chipx86 chipx86

    Same here.

    chipx86 chipx86

    We can use the ColorMode type here.

    maubin maubin

    This comparison should be in parens.

    chipx86 chipx86

    Can you swap these so they're in alphabetical order?

    chipx86 chipx86

    Since order is crucial here, let's make them keyword-only arguments.

    chipx86 chipx86

    Can we import this at the module level?

    chipx86 chipx86

    "Rich"

    chipx86 chipx86

    This is missing docs.

    chipx86 chipx86

    Your other docstrings elsewhere in the change refer to this as "Rich", so we should keep consistent with these. Or …

    chipx86 chipx86

    We should have a Prototype for this, so we can get proper typing and documentation on it.

    chipx86 chipx86

    Let's reference: :py:class:`object.__len__`

    chipx86 chipx86

    Can we import this at the module level?

    chipx86 chipx86

    Private methods go below public.

    chipx86 chipx86

    We can reference ColorMode here.

    chipx86 chipx86

    We should never override _. This is a really big Claude smell (it's always trying to do this, even when …

    chipx86 chipx86

    We should type this and use Final. Also, maybe call it DEFAULT_RBTOOLS_STYLES?

    chipx86 chipx86

    Can we order these alphabetically?

    chipx86 chipx86

    We reference this somewhat-complex type here and elsewhere in the code. Can we get a TypeAlias for it? If it's …

    chipx86 chipx86

    Missing Version Added.

    chipx86 chipx86

    We need a Version added for these. We probably don't need the trailing comment.

    chipx86 chipx86

    'collections.abc.Mapping' imported but unused Column: 5 Error code: F401

    reviewbot reviewbot

    These should be using our standard multi-line form.

    chipx86 chipx86
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    david
    david
    maubin
    1. Ship It!
    2. Show all issues

      Can you add documentation for the COLOR_MODE config key in docs/rbtools/rbt/configuration/users.rst.

    3. rbtools/config/config.py (Diff revision 3)
       
       
      Show all issues

      We can use the ColorMode type here.

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

      The return statements make this a bit wonky to reason about. The code kind of backs this up, because we're checking late into it for a valid value when we've already ruled out one of them.

      I'd suggest:

      if options is None:
          color_mode = 'auto'
      elif getattr(options, 'json_output', False):
          color_mode = 'never'
      else:
          color_mode = getattr(options, 'color', 'auto')
      
          if color_mode not in {'always', 'auto', 'never'}:
              color_mode = 'auto'
      
      if color_mode == 'auto':
          if os.environ.get('NO_COLOR');
              color_mode = 'never'
          elif os.environ.get('FORCE_COLOR');
              color_mode = 'always'
      
      return color_mode
      

      By the time we're at the return, we should have narrowed this to a valid type in all cases, and limited the conditions in which we've forced values.

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

      This can be an if/else.

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

      Can we use if config := self.config so we don't have to re-get the attribute?

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

      We fetch these attributes twice. Let's pull them out.

      1. I know this is something that we've done for performance in hot loops, and where we have a bunch of accesses it's good for readability, but just curious where you're coming from in cases like this where neither motivation seems to apply.

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

      The placement of the parents makes this read kind of funky.

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

      We're accessing self.options.debug several times. Let's pull these out.

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

      We can now do if output_stream := self.output_stream: here.

    9. rbtools/commands/info.py (Diff revision 3)
       
       
       
       
       
      Show all issues

      These can start on the Table( line, or could end with a ) on its own line.

    10. rbtools/commands/info.py (Diff revision 3)
       
       
       
       
       
      Show all issues

      Same here.

    11. rbtools/commands/status.py (Diff revision 3)
       
       
       
       
       
      Show all issues

      Same here.

    12. rbtools/ui/console.py (Diff revision 3)
       
       
      Show all issues

      This comparison should be in parens.

    13. rbtools/ui/console.py (Diff revision 3)
       
       
       
       
       
       
      Show all issues

      Can you swap these so they're in alphabetical order?

    14. rbtools/ui/console.py (Diff revision 3)
       
       
       
      Show all issues

      Since order is crucial here, let's make them keyword-only arguments.

    15. rbtools/ui/console.py (Diff revision 3)
       
       
      Show all issues

      Can we import this at the module level?

    16. rbtools/ui/console.py (Diff revision 3)
       
       
      Show all issues

      "Rich"

    17. rbtools/ui/console.py (Diff revision 3)
       
       
       
       
       
      Show all issues

      This is missing docs.

    18. rbtools/ui/console.py (Diff revision 3)
       
       
      Show all issues

      Your other docstrings elsewhere in the change refer to this as "Rich", so we should keep consistent with these. Or we could go the other way, avoid the capitalization if we want to say "rich" more generically.

      This will apply to instances below as well, depending on the decision.

    19. rbtools/ui/console.py (Diff revision 3)
       
       
       
       
       
      Show all issues

      We should have a Prototype for this, so we can get proper typing and documentation on it.

    20. rbtools/ui/console.py (Diff revision 3)
       
       
      Show all issues

      Let's reference:

      :py:class:`object.__len__`
      
      1. Guessing you meant :py:meth:

    21. rbtools/ui/console.py (Diff revision 3)
       
       
      Show all issues

      Can we import this at the module level?

    22. rbtools/ui/tests/test_console.py (Diff revision 3)
       
       
       
       
      Show all issues

      Private methods go below public.

    23. rbtools/ui/tests/test_console.py (Diff revision 3)
       
       
      Show all issues

      We can reference ColorMode here.

    24. rbtools/ui/tests/test_console.py (Diff revision 3)
       
       
      Show all issues

      We should never override _. This is a really big Claude smell (it's always trying to do this, even when I tell it not to) and not routine in our codebase due to our gettext usage.

      Can just use [0] here or [:2] below, as needed.

      Same below.

    25. rbtools/ui/theme.py (Diff revision 3)
       
       
      Show all issues

      We should type this and use Final.

      Also, maybe call it DEFAULT_RBTOOLS_STYLES?

    26. rbtools/ui/theme.py (Diff revision 3)
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      Can we order these alphabetically?

    27. rbtools/ui/theme.py (Diff revision 3)
       
       
      Show all issues

      We reference this somewhat-complex type here and elsewhere in the code. Can we get a TypeAlias for it?

      If it's these specific types, maybe we'd also want a Literal of keys.

    28. rbtools/ui/theme.py (Diff revision 3)
       
       
       
       
      Show all issues

      Missing Version Added.

    29. rbtools/ui/theme.py (Diff revision 3)
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      We need a Version added for these.

      We probably don't need the trailing comment.

    30. 
        
    david
    Review request changed
    Commits:
    Summary ID
    Add rich to RBTools and replace old modules.
    This change adds the `rich` library as a dependency, and creates the basic framework for rich output. This is based on a combination of Christian and my previous attempts at this work. This creates a new RBToolsConsole which wraps two rich `Console` objects for stdout and stderr. This also includes a few helpers for multi-step operations, some basic status levels, progress, spinners, and table output. This console is first created in a command's `__init__`, but will get recreated after we parse command-line options in order to properly support the new `--color=[auto,always,never]` option. When commands are running in JSON output mode, a handler is pushed onto the console that suppresses output. This allows commands to do what they've always done: unconditionally write to both stdout/stderr and the json output object, and whichever one is expected to run will work. The existing output wrappers have also been updated to write through the console object, so that can take advantage of the same suppression method. All uses of the old `colorama`, `tqdm`, and `texttable` libraries have been replaced with the new rich output, but I've held off on other output prettification for a separate change. Testing Done: - Ran unit tests. - Tested the various values of the `--color` option, the `COLOR_MODE` config key, and the `NO_COLOR` and `FORCE_COLOR` environment variables. - Tested rich output for the `info`, `install`, `post`, and `status` commands.
    kmrpxswxxprsrnyspyktlqwrrvwoxzuw
    Add rich to RBTools and replace old modules.
    This change adds the `rich` library as a dependency, and creates the basic framework for rich output. This is based on a combination of Christian and my previous attempts at this work. This creates a new RBToolsConsole which wraps two rich `Console` objects for stdout and stderr. This also includes a few helpers for multi-step operations, some basic status levels, progress, spinners, and table output. This console is first created in a command's `__init__`, but will get recreated after we parse command-line options in order to properly support the new `--color=[auto,always,never]` option. When commands are running in JSON output mode, a handler is pushed onto the console that suppresses output. This allows commands to do what they've always done: unconditionally write to both stdout/stderr and the json output object, and whichever one is expected to run will work. The existing output wrappers have also been updated to write through the console object, so that can take advantage of the same suppression method. All uses of the old `colorama`, `tqdm`, and `texttable` libraries have been replaced with the new rich output, but I've held off on other output prettification for a separate change. Testing Done: - Ran unit tests. - Tested the various values of the `--color` option, the `COLOR_MODE` config key, and the `NO_COLOR` and `FORCE_COLOR` environment variables. - Tested rich output for the `info`, `install`, `post`, and `status` commands.
    kmrpxswxxprsrnyspyktlqwrrvwoxzuw

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    david
    maubin
    1. Ship It!
    2. 
        
    chipx86
    1. 
        
    2. rbtools/ui/console.py (Diff revision 5)
       
       
       
       
       
      Show all issues

      These should be using our standard multi-line form.

    3. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (be9de98)