-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add flexible configuration path overrides and simplify documentation #25
Conversation
Added config_file_path parameter to Config.__init__. Implemented path priority: param > env (CLI_CODE_CONFIG_FILE) > default. Updated docstrings. Updated tests/test_config.py: Corrected fixture, added override tests, fixed hangs by mocking _load_config. Refactored README.md for conciseness and moved License.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @ipv1337, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request focuses on refactoring the configuration loading mechanism for the CLI code agent. The primary change involves adding a config_file_path parameter to the Config.__init__ method, allowing users to specify the configuration file path directly. The implementation introduces a path priority: parameter > environment variable (CLI_CODE_CONFIG_FILE) > default path (~/.config/cli-code/config.yaml). Additionally, the pull request includes updates to docstrings, corrections to the test suite (tests/test_config.py), and refactoring of the README.md for conciseness and clarity.
Highlights
- Configuration Refactor: Introduces a
config_file_pathparameter toConfig.__init__to allow specifying the configuration file path. - Path Priority: Implements a priority order for determining the configuration file path: parameter > environment variable > default.
- Test Updates: Corrects fixtures, adds override tests, and fixes hangs in
tests/test_config.pyby mocking_load_config. - README Refactor: Refactors
README.mdfor conciseness and moves the License information.
Changelog
Click here to see the changelog
- README.md
- Refactored for conciseness and clarity.
- Consolidated installation instructions and moved detailed guides to
docs/install.md. - Updated the features list and usage examples.
- Removed the separate 'Configuration File' section, integrating the information into the 'Setup' section.
- Removed the 'Running Tests' section.
- src/cli_code/config.py
- Added
config_file_pathparameter toConfig.__init__. - Implemented path priority logic in
_determine_config_path. - Updated docstrings to reflect the new configuration loading mechanism.
- Added type hints for
config_file_pathusingOptionalandUnion. - Added logging for config file path resolution.
- Added
- tests/test_config.py
- Corrected the
mock_config_pathsfixture to usecli-codeinstead ofcli-code-agent. - Added new tests for config path override scenarios.
- Added tests to ensure the config file is created at the custom path.
- Added tests to verify that the config loads from the path specified by the
CLI_CODE_CONFIG_FILEenvironment variable. - Added tests to confirm that the config loads from the path specified by the
__init__parameter. - Added tests to ensure that the
__init__parameter path takes precedence over the environment variable path. - Fixed hangs by mocking
_load_config.
- Corrected the
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A config's path,
A tangled, winding thread,
Param guides the way.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the configuration loading process, adding flexibility in specifying the configuration file path and improving documentation. The changes look good overall, with a clear priority order for configuration sources. The tests have also been updated to reflect these changes. However, there are a few areas that could be improved for clarity and robustness.
Summary of Findings
- Config path resolution fallback: The logic for handling an empty environment variable for the config file path could be simplified to avoid redundant code. Consider consolidating the fallback to the default path.
- Logging consistency: Ensure consistent logging levels (info, debug, warning) are used appropriately throughout the config loading process to aid in debugging and monitoring.
Merge Readiness
The pull request is almost ready for merging. Addressing the comments regarding config path resolution fallback and logging consistency would improve the code's robustness and maintainability. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.
src/cli_code/config.py
Outdated
| if not config_path_str: | ||
| # Fallback if env var was empty string (should not happen with default logic, but safety) | ||
| log.warning("Config file path resolved to empty, falling back to default.") | ||
| home_dir = Path(os.path.expanduser("~")) | ||
| default_dir = home_dir / ".config" / "cli-code" | ||
| self.config_dir = default_dir | ||
| self.config_file = default_dir / "config.yaml" | ||
| source = "fallback default" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback logic is repeated. Consider refactoring to avoid duplication. You could set source to "environment variable (empty)" earlier, and then have a single fallback block after the if not config_path_str check.
if not config_path_str:
# Fallback if env var was empty string (should not happen with default logic, but safety)
log.warning("Config file path resolved to empty, falling back to default.")
source = "fallback default"
home_dir = Path(os.path.expanduser("~"))
default_dir = home_dir / ".config" / "cli-code"
self.config_dir = default_dir
self.config_file = default_dir / "config.yaml"
Code Coverage Report📊 Current Coverage: 89.90% Detailed coverage analysis is available in SonarCloud Coverage Change DetailsThis shows code coverage for changes in this PR. To improve coverage, consider adding tests for new or modified code. |
Code Coverage Report📊 Current Coverage: 90.46% Detailed coverage analysis is available in SonarCloud Coverage Change DetailsThis shows code coverage for changes in this PR. To improve coverage, consider adding tests for new or modified code. |
Code Coverage Report📊 Current Coverage: 90.46% Detailed coverage analysis is available in SonarCloud Coverage Change DetailsThis shows code coverage for changes in this PR. To improve coverage, consider adding tests for new or modified code. |
Code Coverage Report📊 Current Coverage: 90.46% Detailed coverage analysis is available in SonarCloud Coverage Change DetailsThis shows code coverage for changes in this PR. To improve coverage, consider adding tests for new or modified code. |
|



Overview
This PR enhances the configuration system by adding flexibility in how users can specify the config file path. It also streamlines the README to focus on essential information and point to detailed docs.
Key Features
Configuration Path Flexibility: Users can now specify a custom config file path in three ways:
config_file_pathparameter when creating aConfiginstanceCLI_CODE_CONFIG_FILEenvironment variable~/.config/cli-code/config.yaml)Clear Priority Order: When multiple configuration sources exist, they follow a predictable priority:
Parameter > Environment Variable > Default Path
Developer Experience: Updated docstrings and improved error handling make the configuration system more robust and easier to understand.
Documentation & Testing
_load_configto prevent hangsAddresses Review Comments