From cc4be8b0105f7dc592d396f27bfda1d5502bdf7f Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Sat, 12 Jul 2025 13:20:05 +1000 Subject: [PATCH] Handle case when CONSERVANCY_REPOSITORY isn't set at all --- conservancy_beancount/reconcile/statement_reconciler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conservancy_beancount/reconcile/statement_reconciler.py b/conservancy_beancount/reconcile/statement_reconciler.py index 87865cc..904f101 100644 --- a/conservancy_beancount/reconcile/statement_reconciler.py +++ b/conservancy_beancount/reconcile/statement_reconciler.py @@ -702,9 +702,10 @@ def parse_repo_relative_path(path: str) -> str: if not os.path.exists(path): raise argparse.ArgumentTypeError(f'File {path} does not exist.') real_path = os.path.realpath(path) - repo = os.path.realpath(os.getenv('CONSERVANCY_REPOSITORY')) - if not repo: - raise argparse.ArgumentTypeError('$CONSERVANCY_REPOSITORY is not set.') + try: + repo = os.path.realpath(os.environ['CONSERVANCY_REPOSITORY']) + except KeyError: + raise argparse.ArgumentTypeError('$CONSERVANCY_REPOSITORY environment variable is not set.') if not real_path.startswith(repo): raise argparse.ArgumentTypeError( f'File {real_path} does not share a common prefix with $CONSERVANCY_REPOSITORY {repo}.'