Modernize .reviewboardrc configuration management through rbtools.config.

Review Request #13028 — Created May 10, 2023 and submitted

Information

RBTools
release-5.x

Reviewers

This introduces a new rbtools.config module that's responsible for all
configuration management for RBTools. It handles scanning for
.reviewboardrc files, loading them, and providing an object that can
be used for looking up settings.

Half of this is code moved out from rbtools.utils.filesystem and
updated (for typing, cleanup, and moving out config merging support to
the other half).

The other half is the new wrapper for configuration state.

rbtools.config.config.RBToolsConfig (which is not at all a
redundant-sunding namespace) is an object that wraps a loaded
dictionary. This provides a few advantages over the old dictionary:

  • For any RBTools-provided settings, we now have type annotations.
  • We also have default values, which no longer have to live in Option
    or be handled by codepath-specific .get(..., default) calls.
  • Keys can be accessed via dictionary key access as before, or via
    attribute access now.
  • All keys are now documented in one place, with version information.

Custom settings not known to the RBTools codebase are still loaded and
can be accessed.

This will make it easier to create and maintain settings going forward.

Some initial plans for this change were scrapped, such as type
validation on load and config-driven option construction. For the latter
case, the thought was to make parameters, help output, and defaults all
come from the central config, but upon reflection, it was ultimately
decided that that would box us in if we ever wanted to make larger
changes to options. These will remain independent, but a future change
will update options to get their defaults from the central
configuration.

As of now, code is still using the now-deprecated functions for loading
configuration. That will be updated in a separate change.

Unit tests pass.

Used this to post this change, verifying it relied on my aliases and
my Markdown setting in my home directory and the repository settings
in the repository.

Summary ID
Modernize .reviewboardrc configuration management through rbtools.config.
This introduces a new `rbtools.config` module that's responsible for all configuration management for RBTools. It handles scanning for `.reviewboardrc` files, loading them, and providing an object that can be used for looking up settings. Half of this is code moved out from `rbtools.utils.filesystem` and updated (for typing, cleanup, and moving out config merging support to the other half). The other half is the new wrapper for configuration state. `rbtools.config.config.RBToolsConfig` (which is not at all a redundant-sunding namespace) is an object that wraps a loaded dictionary. This provides a few advantages over the old dictionary: * For any RBTools-provided settings, we now have type annotations. * We also have default values, which no longer have to live in `Option` or be handled by codepath-specific `.get(..., default)` calls. * Keys can be accessed via dictionary key access as before, or via attribute access now. * All keys are now documented in one place, with version information. Custom settings not known to the RBTools codebase are still loaded and can be accessed. This will make it easier to create and maintain settings going forward. Some initial plans for this change were scrapped, such as type validation on load and config-driven option construction. For the latter case, the thought was to make parameters, help output, and defaults all come from the central config, but upon reflection, it was ultimately decided that that would box us in if we ever wanted to make larger changes to options. These will remain independent, but a future change will update options to get their defaults from the central configuration. As of now, code is still using the now-deprecated functions for loading configuration. That will be updated in a separate change.
23575892e143d4ae3e8df3573c51fda93d945b1f
Description From Last Updated

'typing_extensions.TypeAlias' imported but unused Column: 1 Error code: F401

reviewbotreviewbot

local variable 'config_file1' is assigned to but never used Column: 9 Error code: F841

reviewbotreviewbot

local variable 'config_file2' is assigned to but never used Column: 9 Error code: F841

reviewbotreviewbot

local variable 'config_file3' is assigned to but never used Column: 9 Error code: F841

reviewbotreviewbot

local variable 'config_file4' is assigned to but never used Column: 9 Error code: F841

reviewbotreviewbot

local variable 'config_file5' is assigned to but never used Column: 9 Error code: F841

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

flake8

chipx86
Review request changed
Change Summary:
  • Removed an unused import.
  • Added the missing loader unit tests.
Commits:
Summary ID
Modernize .reviewboardrc configuration management through rbtools.config.
This introduces a new `rbtools.config` module that's responsible for all configuration management for RBTools. It handles scanning for `.reviewboardrc` files, loading them, and providing an object that can be used for looking up settings. Half of this is code moved out from `rbtools.utils.filesystem` and updated (for typing, cleanup, and moving out config merging support to the other half). The other half is the new wrapper for configuration state. `rbtools.config.config.RBToolsConfig` (which is not at all a redundant-sunding namespace) is an object that wraps a loaded dictionary. This provides a few advantages over the old dictionary: * For any RBTools-provided settings, we now have type annotations. * We also have default values, which no longer have to live in `Option` or be handled by codepath-specific `.get(..., default)` calls. * Keys can be accessed via dictionary key access as before, or via attribute access now. * All keys are now documented in one place, with version information. Custom settings not known to the RBTools codebase are still loaded and can be accessed. This will make it easier to create and maintain settings going forward. Some initial plans for this change were scrapped, such as type validation on load and config-driven option construction. For the latter case, the thought was to make parameters, help output, and defaults all come from the central config, but upon reflection, it was ultimately decided that that would box us in if we ever wanted to make larger changes to options. These will remain independent, but a future change will update options to get their defaults from the central configuration. As of now, code is still using the now-deprecated functions for loading configuration. That will be updated in a separate change.
846e809ef196bc7e8c247e0b15a76f343e3a8a31
Modernize .reviewboardrc configuration management through rbtools.config.
This introduces a new `rbtools.config` module that's responsible for all configuration management for RBTools. It handles scanning for `.reviewboardrc` files, loading them, and providing an object that can be used for looking up settings. Half of this is code moved out from `rbtools.utils.filesystem` and updated (for typing, cleanup, and moving out config merging support to the other half). The other half is the new wrapper for configuration state. `rbtools.config.config.RBToolsConfig` (which is not at all a redundant-sunding namespace) is an object that wraps a loaded dictionary. This provides a few advantages over the old dictionary: * For any RBTools-provided settings, we now have type annotations. * We also have default values, which no longer have to live in `Option` or be handled by codepath-specific `.get(..., default)` calls. * Keys can be accessed via dictionary key access as before, or via attribute access now. * All keys are now documented in one place, with version information. Custom settings not known to the RBTools codebase are still loaded and can be accessed. This will make it easier to create and maintain settings going forward. Some initial plans for this change were scrapped, such as type validation on load and config-driven option construction. For the latter case, the thought was to make parameters, help output, and defaults all come from the central config, but upon reflection, it was ultimately decided that that would box us in if we ever wanted to make larger changes to options. These will remain independent, but a future change will update options to get their defaults from the central configuration. As of now, code is still using the now-deprecated functions for loading configuration. That will be updated in a separate change.
745b76cf6867e9be922c49ed4e745864ecbfec86

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.x (2aa6aa5)