-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information |
|
|
||
| write_file(os.path.join(Agent.get_workspace(task.task_id), file_path), code) | ||
| path = Path("./" + file_path) | ||
| path = Path(f"./{file_path}") |
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.
Function _generate_code refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| ) | ||
| result = file_paths.from_response(completion) | ||
| return result | ||
| return file_paths.from_response(completion) |
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.
Function specify_file_paths refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| chunk_message_dict = chunk["choices"][0] | ||
| chunk_message = chunk_message_dict["delta"] # extract the message | ||
| if chunk_message_dict["finish_reason"] is None: | ||
| chunk_message = chunk_message_dict["delta"] # extract the message |
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.
Function plan refactored with the following changes:
- Move assignments closer to their usage (
move-assign) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
This removes the following comments ( why? ):
# if stream_handler and hasattr(stream_handler, "onComplete"): stream_handler.onComplete('done')
| chunk_message = chunk_message_dict["delta"] # extract the message | ||
| if chunk_message_dict["finish_reason"] is None: | ||
| chunk_message = chunk_message_dict["delta"] # extract the message |
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.
Function generate_code refactored with the following changes:
- Move assignments closer to their usage (
move-assign)
| if not os.path.exists(folder_path): | ||
| os.makedirs(folder_path) | ||
| else: | ||
| if os.path.exists(folder_path): | ||
| shutil.rmtree(folder_path) | ||
| os.makedirs(folder_path) | ||
| os.makedirs(folder_path) |
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.
Function generate_folder refactored with the following changes:
- Hoist nested repeated code outside conditional statements (
hoist-similar-statement-from-if)
| messages = [] | ||
| messages.append({"role": "system", "content": system_prompt}) | ||
| messages.append({"role": "user", "content": user_prompt}) | ||
| messages = [ | ||
| {"role": "system", "content": system_prompt}, | ||
| {"role": "user", "content": user_prompt}, | ||
| ] |
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.
Function generate_response refactored with the following changes:
- Merge append into list declaration [×2] (
merge-list-append) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
This removes the following comments ( why? ):
# Get the reply from the API response
| directory= args.directory | ||
| model=args.model | ||
| directory = args.directory |
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.
Function main refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| messages = [] | ||
| messages.append({"role": "system", "content": system_prompt}) | ||
| messages.append({"role": "user", "content": user_prompt}) | ||
| messages = [ | ||
| {"role": "system", "content": system_prompt}, | ||
| {"role": "user", "content": user_prompt}, | ||
| ] |
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.
Function generate_response refactored with the following changes:
- Merge append into list declaration [×2] (
merge-list-append) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
This removes the following comments ( why? ):
# Get the reply from the API response
|
|
||
| except ValueError: | ||
| print("Failed to parse result: " + result) | ||
| print(f"Failed to parse result: {result}") |
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.
Function main refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| print(filecode) | ||
|
|
||
| file_path = directory + "/" + filename | ||
| file_path = f"{directory}/{filename}" |
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.
Function write_file refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!