Skip to content

Commit 6b57350

Browse files
peterhollenderebrahimebrahim
authored andcommitted
Switch from warnings to logger.warning (#362)
1 parent ea98007 commit 6b57350

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/openlifu/seg/seg_method.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import copy
44
import inspect
5-
import warnings
5+
import logging
66
from abc import ABC, abstractmethod
77
from dataclasses import dataclass, field
88
from typing import Annotated, Any, Literal
@@ -71,7 +71,7 @@ def from_dict(d: dict, on_keyword_mismatch: Literal['warn', 'raise', 'ignore'] =
7171
if on_keyword_mismatch == 'raise':
7272
raise TypeError(f"Unexpected keyword arguments for {short_classname}: {unexpected_keywords}")
7373
elif on_keyword_mismatch == 'warn':
74-
warnings.warn(f"Ignoring unexpected keyword arguments for {short_classname}: {unexpected_keywords}", stacklevel=2)
74+
logging.warning(f"Ignoring unexpected keyword arguments for {short_classname}: {unexpected_keywords}")
7575
for k in unexpected_keywords:
7676
d.pop(k)
7777

tests/test_seg_method.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ def test_from_dict_on_keyword_mismatch():
8787
"ref_material": "water"
8888
}
8989

90-
with pytest.warns(UserWarning):
91-
SegmentationMethod.from_dict(d, on_keyword_mismatch='warn')
92-
9390
with pytest.raises(TypeError, match=r"Unexpected keyword arguments for UniformWater: \['ref_material'\]"):
9491
SegmentationMethod.from_dict(d, on_keyword_mismatch='raise')
9592

0 commit comments

Comments
 (0)