Skip to content

Commit

Permalink
Replace empty collection comparisons w/ a more idiomatic unary operat…
Browse files Browse the repository at this point in the history
…or (#70)

* Replace empty collections comp w/ unary operator

* Correct synthax error in the ternary operation

* peer-review: removing useless comparison to None

As said by @LeStarch, None is also falsey so no need to leave the check here

* Peer-review: correct incorrect changes
  • Loading branch information
ThibFrgsGmz authored Jun 3, 2022
1 parent b678f39 commit 9c5efe5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/fprime/fbuild/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def _communicate(proc, stdout, stderr, print_output=True):
appendable.append(line)
# Streams are EOF when the line returned is empty. Once this occurs, we are responsible for closing the
# stream and thus closing the select loop. Empty strings need not be printed.
if line == "":
if not line:
key.fileobj.close()
continue
# Forwards output to screen. Assuming a PTY is used, then coloring highlights should be automatically
Expand Down
2 changes: 1 addition & 1 deletion src/fprime/fbuild/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def read_safe_path(
all_paths = parser.get(section, key, fallback="").split(":")
expanded = []
for path in all_paths:
if path == "" or path is None:
if not path:
continue
full_path = os.path.abspath(os.path.normpath(os.path.join(base_dir, path)))
if exists and not os.path.exists(full_path):
Expand Down
2 changes: 1 addition & 1 deletion src/fprime/util/string_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def convert(match_obj, ignore_int):
elif all([not ignore_int, str(conversion_type).lower() == "d"]):
format_template += f"{conversion_type}"

return "{}" if format_template == "" else "{:" + format_template + "}"
return "{}" if not format_template else "{:" + format_template + "}"

def convert_include_all(match_obj):
return convert(match_obj, ignore_int=False)
Expand Down

0 comments on commit 9c5efe5

Please sign in to comment.