Skip to content

Sourcery refactored master branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Oct 14, 2023

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from edson-github October 14, 2023 20:11
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

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')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 17-17 refactored with the following changes:

parsing_tests = False
parsing_settings = False
for line in input.readlines():
for line in input:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 41-41 refactored with the following changes:

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}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Interpreter._get_name_and_version refactored with the following changes:

Comment on lines -44 to +55
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,
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Interpreter.os refactored with the following changes:

  • Use the built-in function next instead of a for-loop (use-next)

Comment on lines -128 to +135
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}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestCheckerLibrary.process_output refactored with the following changes:


def get_variables(*args):
if len(args) == 0:
if not args:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_variables refactored with the following changes:


def get_keyword_names(self):
return [key for key in self.kws]
return list(self.kws)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DynamicPositionalOnly.get_keyword_names refactored with the following changes:

if kwargs:
return f"{name}-{args}-{kwargs}"
return f"{name}-{args}"
return f"{name}-{args}-{kwargs}" if kwargs else f"{name}-{args}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DynamicPositionalOnly.run_keyword refactored with the following changes:


def with_normal(posonly, /, normal):
return posonly + '-' + normal
return f'{posonly}-{normal}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with_normal refactored with the following changes:


def defaults(required, optional='default', /):
return required + '-' + optional
return f'{required}-{optional}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function defaults refactored with the following changes:


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())}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function kwargs refactored with the following changes:


def run_keyword(self, name, args):
print("Running keyword '%s'." % name)
print(f"Running keyword '{name}'.")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name.run_keyword refactored with the following changes:


def two_named(self, fst=None, snd=None):
return '%s, %s' % (fst, snd)
return f'{fst}, {snd}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function KwargsLibrary.two_named refactored with the following changes:


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}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function KwargsLibrary.four_named refactored with the following changes:


def mandatory_and_named(self, a, b, c=None):
return '%s, %s, %s' % (a, b, c)
return f'{a}, {b}, {c}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function KwargsLibrary.mandatory_and_named refactored with the following changes:

@keyword(name="${a}*lib*${b}")
def mult_match3(a, b):
log("%s*lib*%s" % (a, b))
log(f"{a}*lib*{b}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function mult_match3 refactored with the following changes:

@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))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function result_of_is refactored with the following changes:

@keyword(name="${a}*lib*${b}")
def mult_match3(a, b):
logger.info("%s*lib*%s" % (a, b))
logger.info(f"{a}*lib*{b}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function mult_match3 refactored with the following changes:


def true(argument: bool):
assert argument is True
assert argument
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function true refactored with the following changes:


def false(argument: bool):
assert argument is False
assert not argument
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function false refactored with the following changes:

def multiply(self, num: Number, expected: int):
self.counter += 1
assert num == int(expected)
assert num == expected
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StatefulLibrary.multiply refactored with the following changes:

def global_multiply(self, num: Number, expected: int):
self.counter += 1
assert num == int(expected)
assert num == expected
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StatefulGlobalLibrary.global_multiply refactored with the following changes:

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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function concrete_types refactored with the following changes:

@decorator
def keyword_using_decorator(args, are_not, preserved=True):
return '%s %s %s' % (args, are_not, preserved)
return f'{args} {are_not} {preserved}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function keyword_using_decorator refactored with the following changes:

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}`.'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DynamicLibrary.get_keyword_documentation refactored with the following changes:

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()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function startTest refactored with the following changes:


def output_file(path):
print("Output: %s" % os.path.basename(path), file=sys.__stderr__)
print(f"Output: {os.path.basename(path)}", file=sys.__stderr__)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function output_file refactored with the following changes:


def log_file(path):
print("Log: %s" % os.path.basename(path), file=sys.__stderr__)
print(f"Log: {os.path.basename(path)}", file=sys.__stderr__)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function log_file refactored with the following changes:


def report_file(path):
print("Report: %s" % os.path.basename(path), file=sys.__stderr__)
print(f"Report: {os.path.basename(path)}", file=sys.__stderr__)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function report_file refactored with the following changes:


def debug_file(path):
print("Debug: %s" % os.path.basename(path), file=sys.__stderr__)
print(f"Debug: {os.path.basename(path)}", file=sys.__stderr__)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function debug_file refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants