Skip to content

Commit

Permalink
bugfix: handle errors in pyproject for cli command finding
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Jan 11, 2022
1 parent 088c652 commit 345c691
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/setuptools_scm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main() -> None:
print(fname)


def _get_cli_opts():
def _get_cli_opts() -> argparse.Namespace:
prog = "python -m setuptools_scm"
desc = "Print project version according to SCM metadata"
parser = argparse.ArgumentParser(prog, description=desc)
Expand Down Expand Up @@ -67,13 +67,15 @@ def _get_cli_opts():
return parser.parse_args()


def _find_pyproject(parent):
def _find_pyproject(parent: str) -> str:
for directory in walk_potential_roots(os.path.abspath(parent)):
pyproject = os.path.join(directory, "pyproject.toml")
if os.path.exists(pyproject):
if os.path.isfile(pyproject):
return pyproject

raise FileNotFoundError("'pyproject.toml' was not found")
return os.path.abspath(
"pyproject.toml"
) # use default name to trigger the default errors


if __name__ == "__main__":
Expand Down

0 comments on commit 345c691

Please sign in to comment.