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

Simplify logical statement by swapping if/else branch in if-expr #64

Merged
merged 5 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fprime/fbuild/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def add_target_parser(
"--pass-through",
nargs=argparse.REMAINDER,
default=[],
help=f"If specified, --pass-through must be the last argument. Remaining arguments passed to underlying executable",
help="If specified, --pass-through must be the last argument. Remaining arguments passed to underlying executable",
)
flags.append("--pass-through")
flags.extend(new_flags)
Expand Down
4 changes: 2 additions & 2 deletions src/fprime/fbuild/gcovr.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def execute(
print(f"[INFO] Making temporary directory: {temp_path}")
temp_path.mkdir(exist_ok=False)
atexit.register(self.removal, temp_path)
print(f"[INFO] Copying AC files into temporary directory")
print("[INFO] Copying AC files into temporary directory")
cache_path = builder.build_dir / builder.get_build_cache_path(context)
recurse_path = (
Path(builder.build_dir)
Expand Down Expand Up @@ -230,7 +230,7 @@ def execute(
)
return
ac_temporary_path = _get_ac_directory(builder, context, self.scope)
coverage_output_dir = context / f"coverage"
coverage_output_dir = context / "coverage"
coverage_output_dir.mkdir(exist_ok=True)
project_root = builder.get_settings(
"project_root",
Expand Down
13 changes: 5 additions & 8 deletions src/fprime/fbuild/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,29 @@ def load(settings_file: Path, platform: str = "fprime"):
proj_root = IniSettings.read_safe_path(
confparse, "fprime", "project_root", settings_file
)
proj_root = None if not proj_root else proj_root[0]
proj_root = proj_root[0] if proj_root else None
# Read ac constants if it is available
ac_consts = IniSettings.read_safe_path(
confparse, platform, "ac_constants", settings_file
)
ac_consts = None if not ac_consts else ac_consts[0]
ac_consts = ac_consts[0] if ac_consts else None
# Read include constants if it is available
config_dir = IniSettings.read_safe_path(
confparse, platform, "config_directory", settings_file
)
config_dir = None if not config_dir else config_dir[0]
config_dir = config_dir[0] if config_dir else None

install_dest = IniSettings.read_safe_path(
confparse, platform, "install_dest", settings_file, False
)

if install_dest:
install_dest = Path(install_dest[0])
else:
install_dest = dfl_install_dest
install_dest = Path(install_dest[0]) if install_dest else dfl_install_dest

# Read separate environment file if necessary
env_file = IniSettings.read_safe_path(
confparse, platform, "environment_file", settings_file
)
env_file = settings_file if not env_file else env_file[0]
env_file = env_file[0] if env_file else settings_file
libraries = IniSettings.read_safe_path(
confparse, platform, "library_locations", settings_file
)
Expand Down
8 changes: 4 additions & 4 deletions src/fprime/fbuild/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def config_string(mnemonic, flags):
Returns:
string of format "mnemonic --flag1 --flag2 ..."
"""
flag_string = " ".join(["--{}".format(flag) for flag in flags])
flag_string = "" if flag_string == "" else " " + flag_string
return "{}{}".format(mnemonic, flag_string)
flag_string = " ".join([f"--{flag}" for flag in flags])
flag_string = f" {flag_string}" if flag_string else ""
return f"{mnemonic}{flag_string}"

@classmethod
def get_all_possible_flags(cls) -> Set[str]:
Expand Down Expand Up @@ -196,7 +196,7 @@ def get_target(cls, mnemonic: str, flags: Set[str]) -> "Target":
matching.append(target)
if not matching:
raise NoSuchTargetException(
"Could not find target '{}'".format(cls.config_string(mnemonic, flags))
f"Could not find target '{cls.config_string(mnemonic, flags)}'"
)
assert len(matching) == 1, "Conflicting targets specified in code"
return matching[0]
Expand Down
8 changes: 2 additions & 6 deletions src/fprime/fbuild/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ def get_suffix(self):
return ""
if self == BuildType.BUILD_TESTING:
return "-ut"
raise InvalidBuildTypeException(
"{} is not a supported build type".format(self.name)
)
raise InvalidBuildTypeException(f"{self.name} is not a supported build type")

def get_cmake_build_type(self):
"""Get the suffix of a directory supporting this build"""
Expand All @@ -71,9 +69,7 @@ def get_cmake_build_type(self):
return "Release"
if self == BuildType.BUILD_CUSTOM:
return "Custom"
raise InvalidBuildTypeException(
"{} is not a supported build type".format(self.name)
)
raise InvalidBuildTypeException(f"{self.name} is not a supported build type")

@staticmethod
def get_public_types() -> List["BuildType"]:
Expand Down
2 changes: 1 addition & 1 deletion src/fprime/util/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def print_info(

# Print out directory and deployment target sections
if local_generic_targets.keys() or global_generic_targets.keys():
print(f"[INFO] fprime build information:")
print("[INFO] fprime build information:")
print(
f" Available directory targets: {' '.join(local_generic_targets.keys())}"
)
Expand Down