Skip to content

Commit

Permalink
Catch the ValueError in both invocations of DepsReader._read.
Browse files Browse the repository at this point in the history
Added a docstring to _read to explicitly declare the intended interface. Closes #105
  • Loading branch information
jaraco committed Jun 22, 2024
1 parent 48dfc07 commit bc7fbf5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pip_run/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,16 @@ def read_python(self):
raw_reqs = suppress(ValueError)(self._read)('__requires__') or []
reqs_items = jaraco.text.yield_lines(raw_reqs)
deps = Dependencies.load(reqs_items)
with contextlib.suppress(Exception):
with contextlib.suppress(ValueError):
deps.index_url = self._read('__index_url__')
return deps

def _read(self, var_name):
"""
Read a variable from self.script by parsing the AST.
Raises ValueError if the variable is not found.
"""
mod = ast.parse(self.script)
(node,) = (
node
Expand Down

0 comments on commit bc7fbf5

Please sign in to comment.