update_settings_from_args

This commit is contained in:
mrT23
2023-07-30 12:04:57 +03:00
parent 3daf94954a
commit 42b047a14e
4 changed files with 13 additions and 24 deletions

View File

@ -222,9 +222,15 @@ def update_settings_from_args(args):
d = settings
for i, v in enumerate(vals[:-1]):
if i == len(vals) - 2:
d[v] = vals[-1]
logging.info(f'Updated setting {vals[:-1]} to: "{vals[-1]}"')
break
if v in d:
if type(d[v]) == bool:
d[v] = vals[-1].lower() in ("yes", "true", "t", "1")
else:
d[v] = type(d[v])(vals[-1])
logging.info(f'Updated setting {vals[:-1]} to: "{vals[-1]}"')
break
else:
logging.error(f'Invalid setting {vals[:-1]}')
else:
d = d[v]
except Exception as e:

View File

@ -31,7 +31,7 @@ reflect - Ask the PR author questions about the PR.
update_changelog - Update the changelog based on the PR's contents.
To edit any configuration parameter from 'configuration.toml', just add -config_path=<value>.
For example: '- cli.py --pr-url=... review --pr_reviewer.extra_instructions="focus on the file: ...'
For example: '- cli.py --pr-url=... review --pr_reviewer.extra_instructions="focus on the file: ..."'
""")
parser.add_argument('--pr_url', type=str, help='The URL of the PR to review', required=True)
parser.add_argument('command', type=str, help='The', choices=['review', 'review_pr',

View File

@ -1,11 +1,10 @@
commands_text = "> **/review [-i]**: Request a review of your Pull Request. For an incremental review, which only " \
"considers changes since the last review, include the '-i' option.\n" \
"> **/describe**: Modify the PR title and description based on the contents of the PR.\n" \
"> **/improve**: Suggest improvements to the code in the PR. " \
"These will be provided as pull request comments, ready to commit.\n" \
"> **/improve**: Suggest improvements to the code in the PR. \n" \
"> **/ask \\<QUESTION\\>**: Pose a question about the PR.\n\n" \
"To edit any configuration parameter from 'configuration.toml', just add -config_path=<value>. " \
"For example: '/review --pr_reviewer.extra_instructions=focus on the file: ...'" \
"For example: '/review --pr_reviewer.extra_instructions=\"focus on the file: ...\"'" \
def bot_help_text(user: str):

View File

@ -55,22 +55,6 @@ class PRDescription:
self.patches_diff = None
self.prediction = None
def parse_args(self, args: List[str]) -> None:
"""
Parse the arguments passed to the PRDescription class and set the 'publish_description_as_comment' attribute accordingly.
Args:
args: A list of arguments passed to the PRReviewer class.
Returns:
None
"""
self.publish_description_as_comment = settings.pr_description.publish_description_as_comment
if args and len(args) >= 1:
arg = args[0]
if arg == "-c":
self.publish_description_as_comment = True
async def describe(self):
"""
Generates a PR description using an AI model and publishes it to the PR.
@ -86,7 +70,7 @@ class PRDescription:
if settings.config.publish_output:
logging.info('Pushing answer...')
if self.publish_description_as_comment:
if settings.pr_description.publish_description_as_comment:
self.git_provider.publish_comment(markdown_text)
else:
self.git_provider.publish_description(pr_title, pr_body)