Skip to content

Commit 7ee5aed

Browse files
authored
Improved check_suffix() robustness to '' and "" (#5192)
* Improved check_suffix() robustness to `''` and `""` * Cleanup
1 parent 0be58f1 commit 7ee5aed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

utils/general.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,14 @@ def check_imshow():
293293

294294

295295
def check_suffix(file='yolov5s.pt', suffix=('.pt',), msg=''):
296-
# Check file(s) for acceptable suffixes
296+
# Check file(s) for acceptable suffix
297297
if file and suffix:
298298
if isinstance(suffix, str):
299299
suffix = [suffix]
300300
for f in file if isinstance(file, (list, tuple)) else [file]:
301-
assert Path(f).suffix.lower() in suffix, f"{msg}{f} acceptable suffix is {suffix}"
301+
s = Path(f).suffix.lower() # file suffix
302+
if len(s):
303+
assert s in suffix, f"{msg}{f} acceptable suffix is {suffix}"
302304

303305

304306
def check_yaml(file, suffix=('.yaml', '.yml')):

0 commit comments

Comments
 (0)