Skip to content

Commit

Permalink
Fix lint issue of viztracerrc convert function
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian committed Oct 14, 2024
1 parent 663c5f4 commit 2e152d9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/viztracer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def load_config_file(self, filename: str = ".viztracerrc") -> argparse.Namespace
raise ValueError("Config file does not contain [default] section")
for action in self.parser._actions:
if hasattr(action, "dest") and action.dest in cfg_parser["default"]:
convert = action.type if action.type is not None else str
if not callable(convert):
# This only happens when action.type is not None but not a callable
# This should not happen in normal case
raise ValueError(f"Invalid action type {action.type}") # pragma: no cover
if action.nargs == 0:
setattr(ret, action.dest, action.const)
elif action.nargs is None or action.nargs == "?":
Expand All @@ -178,10 +183,8 @@ def load_config_file(self, filename: str = ".viztracerrc") -> argparse.Namespace
# when it's a store, but with type == bool
setattr(ret, action.dest, cfg_parser["default"].getboolean(action.dest))
else:
convert = action.type if action.type is not None else str
setattr(ret, action.dest, convert(cfg_parser["default"][action.dest]))
else:
convert = action.type if action.type is not None else str
setattr(ret, action.dest, [convert(val) for val in cfg_parser["default"][action.dest].strip().split()])
else:
if filename != ".viztracerrc":
Expand Down

0 comments on commit 2e152d9

Please sign in to comment.