Skip to content

Commit

Permalink
Replace empty collections comp w/ unary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibFrgsGmz committed May 22, 2022
1 parent 2b81916 commit 225ba2e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/fprime/fbuild/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def execute_known_target(
module = self.get_cmake_module(path, build_dir)
cmake_target = (
module
if target == ""
if not target:
else (f"{module}_{target}".lstrip("_") if not top_target else target)
)
run_args = ["--build", build_dir]
Expand Down 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/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def get_port_input(namespace):

# Fill in blank values with defaults
for key in values:
if values[key] == "":
if not values[key]:
values[key] = defaults[key]
return values

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 or path is None:
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 225ba2e

Please sign in to comment.