Skip to content

Commit fae45f9

Browse files
committed
fix(config[is_pinned_for_op]) Replace assert with ValueError
why: assert is stripped under python -O, making the guard a silent no-op. what: - Replace assert op in _VALID_OPS with if/raise ValueError - Update doctest to expect ValueError instead of AssertionError
1 parent 0596a5a commit fae45f9

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/vcspull/config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,16 +846,18 @@ def is_pinned_for_op(entry: t.Any, op: str) -> bool:
846846
>>> is_pinned_for_op({"repo": "git+x", "options": {"pin": "true"}}, "import")
847847
False
848848
849-
Invalid op raises AssertionError:
849+
Invalid op raises ValueError:
850850
851851
>>> is_pinned_for_op( # doctest: +IGNORE_EXCEPTION_DETAIL
852852
... {"repo": "git+x"}, "bogus"
853853
... )
854854
Traceback (most recent call last):
855855
...
856-
AssertionError: Unknown op: 'bogus'
856+
ValueError: Unknown op: 'bogus'
857857
"""
858-
assert op in _VALID_OPS, f"Unknown op: {op!r}"
858+
if op not in _VALID_OPS:
859+
msg = f"Unknown op: {op!r}"
860+
raise ValueError(msg)
859861
if not isinstance(entry, dict):
860862
return False
861863
opts = entry.get("options")

0 commit comments

Comments
 (0)