Skip to content

Sourcery refactored development branch #12

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

Merged
merged 1 commit into from
Aug 3, 2023
Merged

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Aug 3, 2023

Branch development 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 development branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from gjbex August 3, 2023 07:16
if n < 2:
return 1
else:
return n*fac(n-1)
return 1 if n < 2 else n*fac(n-1)
Copy link
Author

Choose a reason for hiding this comment

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

Function fac refactored with the following changes:

if n == 0 or n == 1:
return 1
else:
return fib(n-1) + fib(n-2)
return 1 if n in [0, 1] else fib(n-1) + fib(n-2)
Copy link
Author

Choose a reason for hiding this comment

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

Function fib refactored with the following changes:

print('account: ' + options.account)
print(f'account: {options.account}')
Copy link
Author

Choose a reason for hiding this comment

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

Lines 22-22 refactored with the following changes:

args = list()
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 parse_job_script refactored with the following changes:

Comment on lines -15 to +20
if name is None:
if self.name is None:
return 'No one to say hello to'
else:
return f'Hello to {self.name}'
else:
if name is not None:
return f'Hello {name}'
if self.name is None:
return 'No one to say hello to'
else:
return f'Hello to {self.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 Hello.to refactored with the following changes:

Comment on lines -40 to +42
data = dict()
data['time'] = list()
data = {'time': []}
for var in meta_data:
data[meta_data[var]] = list()
data[meta_data[var]] = []
Copy link
Author

Choose a reason for hiding this comment

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

Function init_data refactored with the following changes:

Comment on lines -49 to +48
buffer = dict()
buffer = {}
Copy link
Author

Choose a reason for hiding this comment

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

Function parse_data refactored with the following changes:

Comment on lines -71 to +70
data_line = list()
for var in columns:
data_line.append(data[var][time_step])
data_line = [data[var][time_step] for var in columns]
Copy link
Author

Choose a reason for hiding this comment

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

Function write_vcd_data_structure refactored with the following changes:

print("### checking directory '{}'".format(directory),
file=sys.stderr)
print(f"### checking directory '{directory}'", 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.

Lines 19-20 refactored with the following changes:

Comment on lines -12 to -17
person = {
'id': ''.join(random.choices(string.ascii_letters, k=5)),
return {
'id': ''.join(random.choices(string.ascii_letters, k=5)),
'birthyear': random.randint(1950, 2015),
'nr_friends': random.randint(0, 50),
}
return person
Copy link
Author

Choose a reason for hiding this comment

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

Function generate_person refactored with the following changes:

Comment on lines -32 to +31
template = environment.get_template('report.' + options.format)
template = environment.get_template(f'report.{options.format}')
Copy link
Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

Comment on lines -33 to +37
if options.info:
level = logging.INFO
else:
level = logging.WARNING
if options.new_log:
filemode = 'w'
else:
filemode = 'a'
level = logging.INFO if options.info else logging.WARNING
if options.log_file:
log_file = Path(options.log_file)
exists = log_file.exists()
filemode = 'w' if options.new_log else 'a'
Copy link
Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

cmd += ' ' + options.dir
cmd += f' {options.dir}'
Copy link
Author

Choose a reason for hiding this comment

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

Lines 27-27 refactored with the following changes:

Comment on lines -50 to +57
for parent in reversed(parents):
if parent.username() == username:
return parent
return process
return next(
(
parent
for parent in reversed(parents)
if parent.username() == username
),
process,
)
Copy link
Author

Choose a reason for hiding this comment

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

Function find_ancestor refactored with the following changes:

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

Comment on lines -66 to +74
open_files = list()
open_files = []
try:
for file in process.open_files():
try:
if 'r' == file.mode:
if file.mode == 'r':
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_read_open_files refactored with the following changes:

Comment on lines -94 to +98
metrics = dict()
metrics['time'] = Metric('time', lambda x: time.time())
metrics = {'time': Metric('time', lambda x: time.time())}
Copy link
Author

Choose a reason for hiding this comment

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

Function define_actions refactored with the following changes:

Comment on lines -124 to +133
status = list()
status = []
with process.oneshot():
for metric in metrics.values():
if metric.is_active:
status.append(metric.measure(process))
status.extend(
metric.measure(process)
for metric in metrics.values()
if metric.is_active
)
Copy link
Author

Choose a reason for hiding this comment

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

Function process_status refactored with the following changes:

Comment on lines -153 to +169
inactive.append('read_files')
inactive.append('write_files')
inactive.extend(('read_files', 'write_files'))
metrics = define_actions(inactive)
if options.output_file:
file = open(options.output_file, 'w')
else:
file = sys.stdout
file = open(options.output_file, 'w') if options.output_file else sys.stdout
try:
with file:
print(status_header(metrics), file=file)
while True:
process_info = [process_status(process, metrics)]
for child_process in process.children(recursive=True):
process_info.append(process_status(child_process, metrics))
process_info.extend(
process_status(child_process, metrics)
for child_process in process.children(recursive=True)
)
Copy link
Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

return_code = process.wait()
if return_code:
if return_code := process.wait():
Copy link
Author

Choose a reason for hiding this comment

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

Function execute refactored with the following changes:

if node_list:
parent = random.choice(node_list)
else:
parent = doc
parent = random.choice(node_list) if node_list else doc
Copy link
Author

Choose a reason for hiding this comment

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

Function Docs.random refactored with the following changes:

@gjbex gjbex merged commit 01fb9e3 into development Aug 3, 2023
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.

1 participant