Skip to content

Commit 29dfb1c

Browse files
peterhollenderarhowe00
authored andcommitted
Switch from warnings to logger.warning (#362)
1 parent 1cad612 commit 29dfb1c

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
@@ -70,7 +70,7 @@ def from_dict(d: dict, on_keyword_mismatch: Literal['warn', 'raise', 'ignore'] =
7070
if on_keyword_mismatch == 'raise':
7171
raise TypeError(f"Unexpected keyword arguments for {short_classname}: {unexpected_keywords}")
7272
elif on_keyword_mismatch == 'warn':
73-
warnings.warn(f"Ignoring unexpected keyword arguments for {short_classname}: {unexpected_keywords}", stacklevel=2)
73+
logging.warning(f"Ignoring unexpected keyword arguments for {short_classname}: {unexpected_keywords}")
7474
for k in unexpected_keywords:
7575
d.pop(k)
7676

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)