Conversation
| replace = '`{0}.rst <{1}/{0}.rst>`__'.format(text, base_url) | ||
| if search not in LONG_DESCRIPTION: | ||
| raise RuntimeError('{} not found from README.rst'.format(search)) | ||
| raise RuntimeError(f'{search} not found from README.rst') |
There was a problem hiding this comment.
Lines 17-17 refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| parsing_tests = False | ||
| parsing_settings = False | ||
| for line in input.readlines(): | ||
| for line in input: |
There was a problem hiding this comment.
Lines 41-41 refactored with the following changes:
- Iterate over files directly rather than using readlines() (
use-file-iterator)
| encoding='UTF-8') | ||
| except (subprocess.CalledProcessError, FileNotFoundError) as err: | ||
| raise ValueError('Failed to get interpreter version: %s' % err) | ||
| raise ValueError(f'Failed to get interpreter version: {err}') |
There was a problem hiding this comment.
Function Interpreter._get_name_and_version refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| for condition, name in [(self.is_linux, 'Linux'), | ||
| (self.is_osx, 'OS X'), | ||
| (self.is_windows, 'Windows')]: | ||
| if condition: | ||
| return name | ||
| return sys.platform | ||
| return next( | ||
| ( | ||
| name | ||
| for condition, name in [ | ||
| (self.is_linux, 'Linux'), | ||
| (self.is_osx, 'OS X'), | ||
| (self.is_windows, 'Windows'), | ||
| ] | ||
| if condition | ||
| ), | ||
| sys.platform, | ||
| ) |
There was a problem hiding this comment.
Function Interpreter.os refactored with the following changes:
- Use the built-in function
nextinstead of a for-loop (use-next)
| logger.info("Processing output '%s'." % path) | ||
| logger.info(f"Processing output '{path}'.") | ||
| result = Result(root_suite=NoSlotsTestSuite()) | ||
| ExecutionResultBuilder(path).build(result) | ||
| except: | ||
| set_suite_variable('$SUITE', None) | ||
| msg, details = utils.get_error_details() | ||
| logger.info(details) | ||
| raise RuntimeError('Processing output failed: %s' % msg) | ||
| raise RuntimeError(f'Processing output failed: {msg}') |
There was a problem hiding this comment.
Function TestCheckerLibrary.process_output refactored with the following changes:
- Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring)
|
|
||
| def get_variables(*args): | ||
| if len(args) == 0: | ||
| if not args: |
There was a problem hiding this comment.
Function get_variables refactored with the following changes:
- Simplify sequence length comparison (
simplify-len-comparison)
|
|
||
| def get_keyword_names(self): | ||
| return [key for key in self.kws] | ||
| return list(self.kws) |
There was a problem hiding this comment.
Function DynamicPositionalOnly.get_keyword_names refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension)
| if kwargs: | ||
| return f"{name}-{args}-{kwargs}" | ||
| return f"{name}-{args}" | ||
| return f"{name}-{args}-{kwargs}" if kwargs else f"{name}-{args}" |
There was a problem hiding this comment.
Function DynamicPositionalOnly.run_keyword 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)
|
|
||
| def with_normal(posonly, /, normal): | ||
| return posonly + '-' + normal | ||
| return f'{posonly}-{normal}' |
There was a problem hiding this comment.
Function with_normal refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
|
|
||
| def defaults(required, optional='default', /): | ||
| return required + '-' + optional | ||
| return f'{required}-{optional}' |
There was a problem hiding this comment.
Function defaults refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
|
|
||
| def kwargs(x, /, **y): | ||
| return '%s, %s' % (x, ', '.join('%s: %s' % item for item in y.items())) | ||
| return f"{x}, {', '.join('%s: %s' % item for item in y.items())}" |
There was a problem hiding this comment.
Function kwargs refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def run_keyword(self, name, args): | ||
| print("Running keyword '%s'." % name) | ||
| print(f"Running keyword '{name}'.") |
There was a problem hiding this comment.
Function name.run_keyword refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def two_named(self, fst=None, snd=None): | ||
| return '%s, %s' % (fst, snd) | ||
| return f'{fst}, {snd}' |
There was a problem hiding this comment.
Function KwargsLibrary.two_named refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def four_named(self, a=None, b=None, c=None, d=None): | ||
| return '%s, %s, %s, %s' % (a, b, c, d) | ||
| return f'{a}, {b}, {c}, {d}' |
There was a problem hiding this comment.
Function KwargsLibrary.four_named refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def mandatory_and_named(self, a, b, c=None): | ||
| return '%s, %s, %s' % (a, b, c) | ||
| return f'{a}, {b}, {c}' |
There was a problem hiding this comment.
Function KwargsLibrary.mandatory_and_named refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| @keyword(name="${a}*lib*${b}") | ||
| def mult_match3(a, b): | ||
| log("%s*lib*%s" % (a, b)) | ||
| log(f"{a}*lib*{b}") |
There was a problem hiding this comment.
Function mult_match3 refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| @keyword(name=r"Result of ${a:\d+} ${operator:[+-]} ${b:\d+} is ${result}") | ||
| def result_of_is(a, operator, b, result): | ||
| should_be_equal(eval("%s%s%s" % (a, operator, b)), float(result)) | ||
| should_be_equal(eval(f"{a}{operator}{b}"), float(result)) |
There was a problem hiding this comment.
Function result_of_is refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| @keyword(name="${a}*lib*${b}") | ||
| def mult_match3(a, b): | ||
| logger.info("%s*lib*%s" % (a, b)) | ||
| logger.info(f"{a}*lib*{b}") |
There was a problem hiding this comment.
Function mult_match3 refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def true(argument: bool): | ||
| assert argument is True | ||
| assert argument |
There was a problem hiding this comment.
Function true refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison)
|
|
||
| def false(argument: bool): | ||
| assert argument is False | ||
| assert not argument |
There was a problem hiding this comment.
Function false refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison)
| def multiply(self, num: Number, expected: int): | ||
| self.counter += 1 | ||
| assert num == int(expected) | ||
| assert num == expected |
There was a problem hiding this comment.
Function StatefulLibrary.multiply refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast)
| def global_multiply(self, num: Number, expected: int): | ||
| self.counter += 1 | ||
| assert num == int(expected) | ||
| assert num == expected |
There was a problem hiding this comment.
Function StatefulGlobalLibrary.global_multiply refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast)
| def concrete_types(a: int, b: bool, c: list): | ||
| assert a == 42, repr(a) | ||
| assert b is False, repr(b) | ||
| assert not b, repr(b) |
There was a problem hiding this comment.
Function concrete_types refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison)
| @decorator | ||
| def keyword_using_decorator(args, are_not, preserved=True): | ||
| return '%s %s %s' % (args, are_not, preserved) | ||
| return f'{args} {are_not} {preserved}' |
There was a problem hiding this comment.
Function keyword_using_decorator refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| if name == 'nön-äscii Ünicöde': | ||
| return 'Hyvää yötä.\n\nСпасибо! (Unicode)\n\nTags: hyvää, yötä' | ||
| short = 'Dummy documentation for `%s`.' % name | ||
| short = f'Dummy documentation for `{name}`.' |
There was a problem hiding this comment.
Function DynamicLibrary.get_keyword_documentation refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| def startTest(data, result): | ||
| data.name = data.doc = result.name = 'Not visible in results' | ||
| result.doc = (result.doc + ' [start test]').strip() | ||
| result.doc = f'{result.doc} [start test]'.strip() |
There was a problem hiding this comment.
Function startTest refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
|
|
||
| def output_file(path): | ||
| print("Output: %s" % os.path.basename(path), file=sys.__stderr__) | ||
| print(f"Output: {os.path.basename(path)}", file=sys.__stderr__) |
There was a problem hiding this comment.
Function output_file refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def log_file(path): | ||
| print("Log: %s" % os.path.basename(path), file=sys.__stderr__) | ||
| print(f"Log: {os.path.basename(path)}", file=sys.__stderr__) |
There was a problem hiding this comment.
Function log_file refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def report_file(path): | ||
| print("Report: %s" % os.path.basename(path), file=sys.__stderr__) | ||
| print(f"Report: {os.path.basename(path)}", file=sys.__stderr__) |
There was a problem hiding this comment.
Function report_file refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def debug_file(path): | ||
| print("Debug: %s" % os.path.basename(path), file=sys.__stderr__) | ||
| print(f"Debug: {os.path.basename(path)}", file=sys.__stderr__) |
There was a problem hiding this comment.
Function debug_file refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
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!