Skip to content
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

Sourcery refactored devel branch #2

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Apr 22, 2023

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

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

Help us improve this pull request!

def get_args(cls, dist, header=None): # noqa: D205,D400
def get_args(cls, dist, header=None): # noqa: D205,D400
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_args refactored with the following changes:

Comment on lines -66 to +74
temp_val = val_obj.val if not isinstance(val_obj, (SerializableType, ArrayType)) else val_obj.formatted_val
temp_val = (
val_obj.formatted_val
if isinstance(val_obj, (SerializableType, ArrayType))
else val_obj.val
)
fmt_str = template.get_format_str()
if temp_val is None:
return ""
if fmt_str:
return format_string_template(fmt_str, (temp_val,))
return temp_val
return format_string_template(fmt_str, (temp_val,)) if fmt_str else temp_val
Copy link
Author

Choose a reason for hiding this comment

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

Function ChData._compute_display_text refactored with the following changes:

Comment on lines -169 to +177
if verbose and csv:
return f"{time_str_nice},{raw_time_str},{ch_name},{self.id},{display_text}"
if verbose and not csv:
if verbose:
if csv:
return f"{time_str_nice},{raw_time_str},{ch_name},{self.id},{display_text}"
return (
f"{time_str_nice}: {ch_name} ({self.id}) {raw_time_str} {display_text}"
)
if not verbose and csv:
if csv:
Copy link
Author

Choose a reason for hiding this comment

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

Function ChData.get_str refactored with the following changes:

Comment on lines -136 to +140
if verbose and csv:
return f"{time_str},{raw_time_str},{name},{self.id},{arg_str}"
if verbose and not csv:
if verbose:
if csv:
return f"{time_str},{raw_time_str},{name},{self.id},{arg_str}"
return f"{time_str}: {name} ({self.id}) {raw_time_str} : {arg_str}"
if not verbose and csv:
if csv:
Copy link
Author

Choose a reason for hiding this comment

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

Function CmdData.get_str refactored with the following changes:

Comment on lines -42 to +47
self.display_text = event_temp.description if event_args is None else format_string_template(
event_temp.format_str, tuple([arg.val for arg in event_args])
self.display_text = (
event_temp.description
if event_args is None
else format_string_template(
event_temp.format_str, tuple(arg.val for arg in event_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 EventData.__init__ refactored with the following changes:

Comment on lines -41 to -46
channel_list = test_api_utils.get_item_list(
return test_api_utils.get_item_list(
item_dictionary=project_dictionary.channel_id,
search_filter=filter_predicate,
template_to_data=ChData.get_empty_obj,
)
return channel_list
Copy link
Author

Choose a reason for hiding this comment

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

Function ChannelsCommand._get_item_list refactored with the following changes:

closest_matches = difflib.get_close_matches(command_name, known_commands, n=num)
return closest_matches
return difflib.get_close_matches(command_name, known_commands, n=num)
Copy link
Author

Choose a reason for hiding this comment

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

Function CommandSendCommand._get_closest_commands refactored with the following changes:

Comment on lines -133 to +132
cmd_description = item.get_description()
if cmd_description:
if cmd_description := item.get_description():
Copy link
Author

Choose a reason for hiding this comment

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

Function CommandSendCommand._get_item_string refactored with the following changes:

close_matches = cls._get_closest_commands(
if close_matches := cls._get_closest_commands(
api.pipeline.dictionaries, command
)
if close_matches:
):
Copy link
Author

Choose a reason for hiding this comment

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

Function CommandSendCommand._execute_command refactored with the following changes:

Comment on lines -40 to -45
event_list = test_api_utils.get_item_list(
return test_api_utils.get_item_list(
item_dictionary=project_dictionary.event_id,
search_filter=filter_predicate,
template_to_data=EventData.get_empty_obj,
)
return event_list
Copy link
Author

Choose a reason for hiding this comment

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

Function EventsCommand._get_item_list refactored with the following changes:

self.search_string = str(search_string)
self.search_string = search_string
Copy link
Author

Choose a reason for hiding this comment

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

Function contains_search_string.__init__ refactored with the following changes:

new_args = func(*args) # lgtm [py/call/wrong-arguments]
if new_args:
if new_args := func(*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 repeat_until_interrupt refactored with the following changes:

This removes the following comments ( why? ):

# lgtm [py/call/wrong-arguments]

if not ch == False or not ch == True:
ch = True
ch = 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 Channel.changed refactored with the following changes:

vals = [0] + vals
return vals
return [0] + vals
Copy link
Author

Choose a reason for hiding this comment

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

Function Event.deserialize refactored with the following changes:

return [item for item in map(parseArg, args)]
return list(map(parseArg, 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 SeqFileParser.parse refactored with the following changes:

Comment on lines -295 to -299
events_parser = parent_parser.add_parser(
return parent_parser.add_parser(
"events",
description="print out new events that have occurred on the F Prime instance, sorted by timestamp",
)
return events_parser
Copy link
Author

Choose a reason for hiding this comment

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

Function EventsSubparserInjector.create_subparser refactored with the following changes:

Comment on lines -92 to +96
flask_env = os.environ.copy()
flask_env.update(
{
"FLASK_APP": "fprime_gds.flask.app",
"STANDARD_PIPELINE_ARGUMENTS": "|".join(reproduced_arguments),
"SERVE_LOGS": "YES",
}
)
flask_env = os.environ | {
"FLASK_APP": "fprime_gds.flask.app",
"STANDARD_PIPELINE_ARGUMENTS": "|".join(reproduced_arguments),
"SERVE_LOGS": "YES",
}
Copy link
Author

Choose a reason for hiding this comment

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

Function launch_html refactored with the following changes:

data = tlm_packet_size + packet[4 : 4 + size]

return data
return tlm_packet_size + packet[4 : 4 + size]
Copy link
Author

Choose a reason for hiding this comment

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

Function ThreadedUDPRequestHandler.readData refactored with the following changes:

except (KeyboardInterrupt, OSError, InterruptedError):
except (KeyboardInterrupt, OSError):
Copy link
Author

Choose a reason for hiding this comment

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

Function register_process_assassin refactored with the following changes:

Comment on lines +14 to +19

import sys

PY3 = sys.version_info[0] == 3

if PY3:
string_types = (str,)
else:
string_types = (basestring,)

string_types = (str, ) if PY3 else (basestring, )
Copy link
Author

Choose a reason for hiding this comment

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

Lines 18-22 refactored with the following changes:

Comment on lines -194 to +204
allow_extns = tuple(config.get(prefix + "ALLOW", ()))
deny_extns = tuple(config.get(prefix + "DENY", ()))
destination = config.get(prefix + "DEST")
base_url = config.get(prefix + "URL")

if destination is None:
# the upload set's destination wasn't given
if uset.default_dest:
# use the "default_dest" callable
destination = uset.default_dest(app)
if destination is None: # still
# use the default dest from the config
if defaults["dest"] is not None:
using_defaults = True
destination = os.path.join(defaults["dest"], uset.name)
else:
raise RuntimeError(f"no destination for set {uset.name}")
allow_extns = tuple(config.get(f"{prefix}ALLOW", ()))
deny_extns = tuple(config.get(f"{prefix}DENY", ()))
destination = config.get(f"{prefix}DEST")
base_url = config.get(f"{prefix}URL")

if destination is None and uset.default_dest:
# use the "default_dest" callable
destination = uset.default_dest(app)
if destination is None: # still
if defaults["dest"] is None:
raise RuntimeError(f"no destination for set {uset.name}")

using_defaults = True
destination = os.path.join(defaults["dest"], uset.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 config_for_set refactored with the following changes:

This removes the following comments ( why? ):

# use the default dest from the config
# the upload set's destination wasn't given

jsonable_dict.update({"name": input_type.__name__})
jsonable_dict["name"] = input_type.__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 jsonify_base_type refactored with the following changes:

event = EventData([], time_type.TimeType(), sample_template)
return event
return EventData([], time_type.TimeType(), sample_template)
Copy link
Author

Choose a reason for hiding this comment

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

Function sample_event refactored with the following changes:

event = EventData(tuple(), TimeType(), temp)
return event
return EventData(tuple(), TimeType(), temp)
Copy link
Author

Choose a reason for hiding this comment

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

Function APITestCases.get_severity_event refactored with the following changes:

Comment on lines -782 to +781
assert True, "api raised the correct error"
pass
Copy link
Author

Choose a reason for hiding this comment

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

Function APITestCases.test_assert_telemetry refactored with the following changes:

Comment on lines -816 to +815
assert True, "api raised the correct error"
pass
Copy link
Author

Choose a reason for hiding this comment

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

Function APITestCases.test_assert_telemetry_sequence refactored with the following changes:

Comment on lines -856 to +855
assert True, "api raised the correct error"
pass
Copy link
Author

Choose a reason for hiding this comment

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

Function APITestCases.test_assert_telemetry_count refactored with the following changes:

@@ -28,7 +28,6 @@ def check_str(pred):
try:
pred.__str__()
print(pred)
assert True, f"predicate provides string summary: {str(pred)}"
Copy link
Author

Choose a reason for hiding this comment

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

Function PredicateTestCases.check_str refactored with the following changes:

@@ -69,7 +68,6 @@ def test_Implemented():
str(pred)
except NotImplementedError:
assert False, "invoking __str__ on an complete subclass of predicate failed"
assert True, "implemented predicate had no problems invoking functions"
Copy link
Author

Choose a reason for hiding this comment

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

Function PredicateTestCases.test_Implemented refactored with the following changes:

@@ -62,7 +62,7 @@
else:
process.kill(signal.SIGINT)
time.sleep(1)
except (KeyboardInterrupt, OSError, InterruptedError):
except (KeyboardInterrupt, OSError):

Check notice

Code scanning / CodeQL

Empty except

'except' clause does nothing but pass and there is no explanatory comment.
@@ -71,13 +71,13 @@
process.kill()
else:
process.kill(signal.SIGKILL)
except (KeyboardInterrupt, OSError, InterruptedError):
except (KeyboardInterrupt, OSError):

Check notice

Code scanning / CodeQL

Empty except

'except' clause does nothing but pass and there is no explanatory comment.
pass
# Might as well close the log file because dead men tell no tales.
try:
if log is not None:
log.close()
except (KeyboardInterrupt, OSError, InterruptedError):
except (KeyboardInterrupt, OSError):

Check notice

Code scanning / CodeQL

Empty except

'except' clause does nothing but pass and there is no explanatory comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
0 participants