Sourcery refactored master branch#1
Conversation
| path = lambda root, fn: root / "{}.py".format(fn) | ||
| # if file_name == "menu" or file_name == "stats": | ||
| # full_path = path(ext, file_name) | ||
| path = lambda root, fn: root / f"{fn}.py" |
There was a problem hiding this comment.
Function Parser.__init__ refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
This removes the following comments ( why? ):
# if file_name == "menu" or file_name == "stats":
# full_path = path(ext, file_name)
| return "{} on or around line {} in `{}`.".format( | ||
| self.data["message"], self.data["start_pos"], self.data["full_path"] | ||
| ) | ||
| return f'{self.data["message"]} on or around line {self.data["start_pos"]} in `{self.data["full_path"]}`.' |
There was a problem hiding this comment.
Function Parser.message refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| if isinstance(result, (generator, chain, map)): | ||
| process = list(result) | ||
| return ( | ||
| Parser(None, process[0]) if len(process) == 1 else Parser(None, process) | ||
| ) | ||
| else: | ||
| if not isinstance(result, (generator, chain, map)): | ||
| return Parser(None, result) | ||
| process = list(result) | ||
| return ( | ||
| Parser(None, process[0]) if len(process) == 1 else Parser(None, process) | ||
| ) |
There was a problem hiding this comment.
Function Parser.execute refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| return Parser(None, [flatten(self.execute("$.body[@.type is 'FunctionDef' and @.name is '{}']".format( | ||
| name | ||
| return Parser( | ||
| None, | ||
| [ | ||
| flatten( | ||
| self.execute( | ||
| f"$.body[@.type is 'FunctionDef' and @.name is '{name}']" | ||
| ).n | ||
| ) | ||
| ], | ||
| ) | ||
| ).n)]) |
There was a problem hiding this comment.
Function Parser.def_args_ refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| "$.body[@.type is 'FunctionDef' and @.name is '{}'].(name, args, body, decorator_list)".format( | ||
| name | ||
| ) | ||
| f"$.body[@.type is 'FunctionDef' and @.name is '{name}'].(name, args, body, decorator_list)" |
There was a problem hiding this comment.
Function Parser.defines refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| return ("Mismatch at {}.\n" "Found : {}\n" "Expected: {}").format( | ||
| format_path(self.path), self.got, self.expected | ||
| ) | ||
| return f"Mismatch at {format_path(self.path)}.\nFound : {self.got}\nExpected: {self.expected}" |
There was a problem hiding this comment.
Function TemplateMismatch.__str__ refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| return "At {}, found {} node instead of {}".format( | ||
| format_path(self.path), type(self.got).__name__, expected | ||
| ) | ||
| return f"At {format_path(self.path)}, found {type(self.got).__name__} node instead of {expected}" |
There was a problem hiding this comment.
Function TemplateNodeTypeMismatch.__str__ refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| return "At {}, found {} node(s) instead of {}".format( | ||
| format_path(self.path), len(self.got), len(self.expected) | ||
| ) | ||
| return f"At {format_path(self.path)}, found {len(self.got)} node(s) instead of {len(self.expected)}" |
There was a problem hiding this comment.
Function TemplateNodeListMismatch.__str__ refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| return ("At {}, lists differ.\nFound : {}\nExpected: {}").format( | ||
| format_path(self.path), self.got, self.expected | ||
| ) | ||
| return f"At {format_path(self.path)}, lists differ.\nFound : {self.got}\nExpected: {self.expected}" |
There was a problem hiding this comment.
Function TemplatePlainListMismatch.__str__ refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| path + | ||
| ["kwonlyargs"], "(missing)", "keyword arg %s" % argname | ||
| path + ["kwonlyargs"], "(missing)", f"keyword arg {argname}" |
There was a problem hiding this comment.
Function DefArgsCheck.__call__ refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring) - Use named expression to simplify assignment and conditional (
use-named-expression)
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!