Skip to content

Commit 99066bc

Browse files
committed
Replace fileset production asserts with explicit exceptions
Signed-off-by: HudaHajira <hudahajira744@gmail.com>
1 parent a109ca4 commit 99066bc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/commoncode/fileset.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ def get_matches(path, patterns, all_matches=False):
119119

120120
matches = []
121121
if not isinstance(patterns, dict):
122-
assert isinstance(patterns, (list, tuple)), "Invalid patterns: {}".format(patterns)
122+
if not isinstance(patterns, (list, tuple)):
123+
raise TypeError("Invalid patterns: {}".format(patterns))
124+
123125
patterns = {p: p for p in patterns}
124126

125127
for pat, value in patterns.items():
@@ -158,7 +160,8 @@ def load(location):
158160
return tuple()
159161
fn = os.path.abspath(os.path.normpath(os.path.expanduser(location)))
160162
msg = ("File %(location)s does not exist or not a file.") % locals()
161-
assert os.path.exists(fn) and os.path.isfile(fn), msg
163+
if not os.path.exists(fn) or not os.path.isfile(fn):
164+
raise FileNotFoundError(msg)
162165
mode = "r"
163166
with open(fn, mode) as f:
164167
return [line.strip() for line in f if line and line.strip()]

0 commit comments

Comments
 (0)