Skip to content

Commit 9b58487

Browse files
committed
Ensure type narrowing pattern is matched
1 parent 6ea1653 commit 9b58487

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

harp/schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def _read_common_registers() -> Registers:
1414
def read_schema(
1515
file: Union[str, PathLike, TextIO], include_common_registers: bool = True
1616
) -> Model:
17-
if isinstance(file, TextIO):
17+
if isinstance(file, (str, PathLike)):
18+
with open(file) as fileIO:
19+
return read_schema(fileIO)
20+
else:
1821
schema = parse_yaml_raw_as(Model, file.read())
1922
if not "WhoAmI" in schema.registers and include_common_registers:
2023
common = _read_common_registers()
@@ -24,6 +27,3 @@ def read_schema(
2427
if schema.groupMasks is not None and common.groupMasks is not None:
2528
schema.groupMasks = dict(common.groupMasks, **schema.groupMasks)
2629
return schema
27-
else:
28-
with open(file) as fileIO:
29-
return read_schema(fileIO, include_common_registers)

0 commit comments

Comments
 (0)