Skip to content

Commit acb33ec

Browse files
committed
ENH: added deprecation warning for now-unused method
This should have been a private method but since it was public, I added the deprecation warning to avoid breaking users code. I also removed the Optional for the exclude argument since the code does not actually work with exclude=None
1 parent 608dfcd commit acb33ec

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

larray/core/checked.py

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

44
import numpy as np
55

6-
from typing import Type, Any, Dict, Set, no_type_check, Optional, Annotated
6+
from typing import Type, Any, Dict, Set, no_type_check, Annotated
77

88
from larray.core.axis import AxisCollection
99
from larray.core.array import Array, full
@@ -467,9 +467,18 @@ def __getstate__(self) -> Dict[str, Any]:
467467
def __setstate__(self, state: Dict[str, Any]) -> None:
468468
object.__setattr__(self, '__dict__', state['__dict__'])
469469

470-
def dict(self, exclude: Optional[Set[str]] = None) -> Dict[str, Any]:
470+
def dict(self, exclude: Set[str]) -> Dict[str, Any]:
471+
warnings.warn(
472+
"checked_session.dict(exclude) is deprecated. Use a dict "
473+
"comprehension instead: "
474+
"{k: v for k, v in checked_session.items() if k not in exclude}"
475+
"\nIf you use this method a lot, please complain and we may "
476+
"add it back in a better form.",
477+
FutureWarning, stacklevel=2)
478+
471479
return {k: v for k, v in self.items() if k not in exclude}
472480

481+
473482
class CheckedParameters(CheckedSession):
474483
"""
475484
Same as py:class:`CheckedSession` but declared variables cannot be modified after initialization.

0 commit comments

Comments
 (0)