From 398a1300dc5a0bf94c49c825999b05829bc17c49 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 19 May 2024 06:23:28 -0700 Subject: [PATCH] aider: Added --auto-lint/--no-auto-lint switch to the parser in aider/args.py. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Aider chat conversation: USER: add a --auto-lint/--no-auto-lint switch ASSISTANT: To add the `--auto-lint/--no-auto-lint` switch, we need to: 1. Add the new argument to the parser in `aider/args.py`. Here is the *SEARCH/REPLACE* block: aider/args.py ```python <<<<<<< SEARCH ) ======= ) group.add_argument( "--auto-lint", action=argparse.BooleanOptionalAction, default=True, help="Enable/disable automatic linting after changes (default: True)", ) >>>>>>> REPLACE ``` USER: # Fix any errors below ## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source aider/args.py aider/args.py:17:5: F821 undefined name 'group' group.add_argument( ^ ## See relevant line below marked with █. /Users/gauthier/Projects/aider/aider/args.py: ...⋮... 9│def get_parser(default_config_files, git_root): 10│ parser = configargparse.ArgumentParser( 11│ description="aider is GPT powered coding in your terminal", 12│ add_config_file_help=True, 13│ default_config_files=default_config_files, 14│ config_file_parser_class=configargparse.YAMLConfigFileParser, 15│ auto_env_var_prefix="AIDER_", 16│ ) 17█ group.add_argument( 18│ "--auto-lint", 19│ action=argparse.BooleanOptionalAction, 20│ default=True, 21│ help="Enable/disable automatic linting after changes (default: True)", ...⋮... ASSISTANT: To fix the error, we need to move the `--auto-lint` argument addition to the correct location within the `get_parser` function, after the `group` variable is defined. Here is the corrected *SEARCH/REPLACE* block: aider/args.py ```python <<<<<<< SEARCH group.add_argument( "--auto-lint", action=argparse.BooleanOptionalAction, default=True, help="Enable/disable automatic linting after changes (default: True)", ) ########## ======= ########## group.add_argument( "--auto-lint", action=argparse.BooleanOptionalAction, default=True, help="Enable/disable automatic linting after changes (default: True)", ) >>>>>>> REPLACE ``` USER: # Fix any errors below ## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source aider/args.py aider/args.py:18:5: F821 undefined name 'group' group.add_argument( ^ ## See relevant line below marked with █. /Users/gauthier/Projects/aider/aider/args.py: ...⋮... 9│def get_parser(default_config_files, git_root): 10│ parser = configargparse.ArgumentParser( 11│ description="aider is GPT powered coding in your terminal", 12│ add_config_file_help=True, 13│ default_config_files=default_config_files, 14│ config_file_parser_class=configargparse.YAMLConfigFileParser, 15│ auto_env_var_prefix="AIDER_", 16│ ) 17│ ########## 18█ group.add_argument( 19│ "--auto-lint", 20│ action=argparse.BooleanOptionalAction, 21│ default=True, 22│ help="Enable/disable automatic linting after changes (default: True)", ...⋮... ASSISTANT: The error is occurring because the `group` variable is not defined before it is used. We need to place the `--auto-lint` argument addition after the `group` variable is defined. Here is the corrected *SEARCH/REPLACE* block: aider/args.py ```python <<<<<<< SEARCH ########## group.add_argument( "--auto-lint", action=argparse.BooleanOptionalAction, default=True, help="Enable/disable automatic linting after changes (default: True)", ) ======= group = parser.add_argument_group("Main") >>>>>>> REPLACE ``` aider/args.py ```python <<<<<<< SEARCH group.add_argument( ======= group.add_argument( "--auto-lint", action=argparse.BooleanOptionalAction, default=True, help="Enable/disable automatic linting after changes (default: True)", ) group.add_argument( >>>>>>> REPLACE ``` --- aider/args.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aider/args.py b/aider/args.py index 3766f845f..1689621a2 100644 --- a/aider/args.py +++ b/aider/args.py @@ -14,14 +14,14 @@ def get_parser(default_config_files, git_root): config_file_parser_class=configargparse.YAMLConfigFileParser, auto_env_var_prefix="AIDER_", ) - ########## + group = parser.add_argument_group("Main") + group = parser.add_argument_group("Main") group.add_argument( "--auto-lint", action=argparse.BooleanOptionalAction, default=True, help="Enable/disable automatic linting after changes (default: True)", ) - group = parser.add_argument_group("Main") group.add_argument( "files", metavar="FILE",