Sourcery Starbot ⭐ refactored wklken/py-patterns#5
Sourcery Starbot ⭐ refactored wklken/py-patterns#5SourceryAI wants to merge 1 commit intowklken:masterfrom
Conversation
| def handle_request(self, request): | ||
| if 0 <= request < 10: | ||
| print("%s process %s" % (self.__class__.__name__, request)) | ||
| print(f"{self.__class__.__name__} process {request}") |
There was a problem hiding this comment.
Function ConcreteHandlerA.handle_request refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| def handle_request(self, request): | ||
| if 10 <= request < 20: | ||
| print("%s process %s" % (self.__class__.__name__, request)) | ||
| print(f"{self.__class__.__name__} process {request}") |
There was a problem hiding this comment.
Function ConcreteHandlerB.handle_request refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| def handle_request(self, request): | ||
| if 20 <= request < 30: | ||
| print("%s process %s" % (self.__class__.__name__, request)) | ||
| print(f"{self.__class__.__name__} process {request}") |
There was a problem hiding this comment.
Function ConcreteHandlerC.handle_request refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| l = [] | ||
| l.append(TerminalExpression()) | ||
| l = [TerminalExpression()] |
There was a problem hiding this comment.
Lines 82-83 refactored with the following changes:
- Merge append into list declaration (
merge-list-append)
| if self.i < self.n: | ||
| i = self.i | ||
| self.i += 1 | ||
| return i | ||
| else: | ||
| if self.i >= self.n: | ||
| raise StopIteration() | ||
| i = self.i | ||
| self.i += 1 | ||
| return i |
There was a problem hiding this comment.
Function YRange.__next__ refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
|
|
||
| def __str__(self): | ||
| return "ProductA: %s" % self.name | ||
| return f"ProductA: {self.name}" |
There was a problem hiding this comment.
Function AbstractProductA.__str__ refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def __str__(self): | ||
| return "ProductB: %s" % self.name | ||
| return f"ProductB: {self.name}" |
There was a problem hiding this comment.
Function AbstractProductB.__str__ refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def show(self): | ||
| print('-'.join(item for item in self.__parts)) | ||
| print('-'.join(self.__parts)) |
There was a problem hiding this comment.
Function Product.show refactored with the following changes:
- Simplify generator expression (
simplify-generator)
| return self.__instance | ||
| else: | ||
| return self.__instance | ||
| return self.__instance |
There was a problem hiding this comment.
Function Singleton.__call__ refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if)
|
|
||
| def __init__(self): | ||
| self.__flyweights = dict() | ||
| self.__flyweights = {} |
There was a problem hiding this comment.
Function FlyweightFactory.__init__ refactored with the following changes:
- Replace
dict()with{}(dict-literal)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: