Skip to content

Commit

Permalink
summon: fix open() shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
Suor committed Jan 10, 2020
1 parent afd29e5 commit c548b07
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dvc/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from builtins import open as builtin_open
import importlib
import os
import sys
Expand All @@ -11,7 +12,7 @@
from voluptuous import Schema, Required, Invalid

from dvc.repo import Repo
from dvc.exceptions import DvcException, FileMissingError
from dvc.exceptions import DvcException
from dvc.external_repo import external_repo


Expand Down Expand Up @@ -123,8 +124,8 @@ def _get_object_from_summon_file(name, path):
and return its description.
"""
try:
with open(path, "r") as fobj:
content = SUMMON_SCHEMA(ruamel.yaml.safe_load(fobj.read()))
with builtin_open(path, "r") as fd:
content = SUMMON_SCHEMA(ruamel.yaml.safe_load(fd.read()))
objects = [x for x in content["objects"] if x["name"] == name]

if not objects:
Expand All @@ -136,8 +137,8 @@ def _get_object_from_summon_file(name, path):

return objects[0]

except FileMissingError:
raise SummonError("Summon file not found")
except FileNotFoundError as exc:
raise SummonError("Summon file not found") from exc
except ruamel.yaml.YAMLError as exc:
raise SummonError("Failed to parse summon file") from exc
except Invalid as exc:
Expand Down

0 comments on commit c548b07

Please sign in to comment.