-
Notifications
You must be signed in to change notification settings - Fork 3
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
Sourcery refactored master branch #8
Conversation
if isinstance(other, ChainContext): | ||
self.primary_map.maps[0:0] = other.primary_map | ||
self.fallback_map.maps[0:0] = other.fallback_map | ||
else: | ||
if not isinstance(other, ChainContext): | ||
return super().__ior__(other) | ||
self.primary_map.maps[:0] = other.primary_map | ||
self.fallback_map.maps[:0] = other.fallback_map |
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 ChainContext.__ior__
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
) - Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] [×2] (
remove-redundant-slice-index
)
if isinstance(chain, Chain): | ||
return Chain(self, *chain) | ||
else: | ||
return Chain(self, chain) | ||
return Chain(self, *chain) if isinstance(chain, Chain) else Chain(self, chain) |
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 Node.next
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
class Message(TypedDict): # type: ignore | ||
role: Role | ||
content: str | ||
name: NotRequired[str] | ||
|
||
else: | ||
from typing_extensions import NotRequired, TypedDict | ||
|
||
class Message(TypedDict): | ||
role: Role | ||
content: str | ||
name: NotRequired[str] | ||
class Message(TypedDict): # type: ignore | ||
role: Role | ||
content: str | ||
name: NotRequired[str] |
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.
Lines 11-22
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
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 is wrong. These changes are introducing new static-type-checking failures.
match = is_message_start.match(line) | ||
if match: | ||
if match := is_message_start.match(line): |
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 parse_chat_markup
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
if op == "if" or op == "for" or op == "while": | ||
if op in ["if", "for", "while"]: | ||
self._ops_stack.append(op) | ||
self._flush() | ||
self._builder.add_line(f"{inner}:") | ||
self._builder.indent() | ||
|
||
elif op == "else" or op == "elif": | ||
elif op in ["else", "elif"]: |
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 TemplateCore._on_special_token
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator [×2] (merge-comparisons
)
Branch
master
refactored 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
master
branch, then run:Help us improve this pull request!