-
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
| if lines[0].split("?")[-1].strip() == "Yes": | ||
| tool = lines[1].split(":", 1)[-1].strip() | ||
| command = lines[2].split(":", 1)[-1].strip() | ||
| return tool, command | ||
| else: | ||
| if lines[0].split("?")[-1].strip() != "Yes": | ||
| return Break() | ||
| tool = lines[1].split(":", 1)[-1].strip() | ||
| command = lines[2].split(":", 1)[-1].strip() | ||
| return tool, command |
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 tool_parse refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| for i, tool in enumerate(tools): | ||
| if selector == tool.__class__.__name__: | ||
| return model(command, tool_num=i) | ||
| return ("",) | ||
| return next( | ||
| ( | ||
| model(command, tool_num=i) | ||
| for i, tool in enumerate(tools) | ||
| if selector == tool.__class__.__name__ | ||
| ), | ||
| ("",), | ||
| ) |
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 tool_use refactored with the following changes:
- Use the built-in function
nextinstead of a for-loop (use-next)
| return "" | ||
|
|
||
| return model(state.next_query) | ||
| return "" if state.next_query is None else model(state.next_query) |
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 google refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp)
| for i in range(3): | ||
| for _ in range(3): |
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 selfask refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| def enum(x: Type[Enum]) -> Dict[str, int]: | ||
| d = {e.name: e.value for e in x} | ||
| return d | ||
| return {e.name: e.value for e in x} |
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 enum refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| else: | ||
| self.backend = backend | ||
|
|
||
| self.backend = [backend] if not isinstance(backend, List) else backend |
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 Prompt.__init__ refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| for r in self.stream(model_input, tool_num): | ||
| yield r | ||
| yield from self.stream(model_input, tool_num) |
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 Prompt.Model.__call__ refactored with the following changes:
- Replace yield inside for loop with yield from (
yield-from)
| if isinstance(s, str): | ||
| return {"string": s} | ||
| return s | ||
| return {"string": s} if isinstance(s, str) else s |
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 to_gradio_block refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp)
| if all([k in os.environ for k in keys]): | ||
| if all(k in os.environ for k in keys): |
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 api_keys refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| inputs = list([gr.Textbox(label=f) for f in fields]) | ||
| inputs = [gr.Textbox(label=f) for f in fields] |
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 show refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension) - Replace unneeded comprehension with generator (
comprehension-to-generator)
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!