Skip to content

Commit cef6ec5

Browse files
committed
Use get to simplify handling of default values
Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent 7fba427 commit cef6ec5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

codebasin/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ def from_json(cls, instance: dict):
112112
CompileCommand
113113
A CompileCommand corresponding to the JSON object.
114114
"""
115-
directory = instance["directory"] if "directory" in instance else None
116-
arguments = instance["arguments"] if "arguments" in instance else None
117-
command = instance["command"] if "command" in instance else None
118-
output = instance["output"] if "output" in instance else None
115+
directory = instance.get("directory", None)
116+
arguments = instance.get("arguments", None)
117+
command = instance.get("command", None)
118+
output = instance.get("output", None)
119119
return cls(
120120
instance["file"],
121121
directory=directory,

0 commit comments

Comments
 (0)