Skip to content

Commit

Permalink
DEP: Deprecate function_eq
Browse files Browse the repository at this point in the history
  • Loading branch information
BvB93 committed Apr 11, 2023
1 parent 8fcfa67 commit 80aa712
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
6 changes: 6 additions & 0 deletions assertionlib/assertion_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""

import warnings
import dis
from types import FunctionType
from itertools import zip_longest
Expand Down Expand Up @@ -137,6 +138,11 @@ def function_eq(func1: FunctionType, func2: FunctionType) -> bool:
or any other object with access to the :attr:`__code__` attribute.
"""
warnings.warn(
"`function_eq` is deprecated and will be removed in the future",
DeprecationWarning, stacklevel=2,
)

code1 = None
try:
code1 = func1.__code__
Expand Down
5 changes: 0 additions & 5 deletions assertionlib/manager.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,4 @@ class AssertionManager(AbstractDataClass, metaclass=_MetaAM):
@overload
def str_eq(self, *args: Any, exception: Type[Exception], invert: bool = ..., post_process: Callable[[Any], Any] | None = ..., message: str | None = ..., **kwargs: Any) -> None: ...

@overload
def function_eq(self, __func1: _SupportsCode, __func2: _SupportsCode, *, exception: None = ..., invert: bool = ..., post_process: Callable[[bool], object] | None = ..., message: str | None = ...) -> None: ...
@overload
def function_eq(self, *args: Any, exception: Type[Exception], invert: bool = ..., post_process: Callable[[Any], Any] | None = ..., message: str | None = ..., **kwargs: Any) -> None: ...

assertion: Final[AssertionManager] = ...
13 changes: 0 additions & 13 deletions tests/test_manager_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,6 @@ def test_shape_eq() -> None:
assertion.shape_eq(shape, ar1, exception=AttributeError)


def test_function_eq() -> None:
"""Test :meth:`AssertionManager.function_eq`."""
func1 = lambda x: x + 5 # noqa: E731
func2 = lambda x: x + 5 # noqa: E731
func3 = lambda x: 5 + x # noqa: E731
func4 = lambda x: x / 5 + 9.0**2 # noqa: E731

assertion.function_eq(func1, func2)
assertion.function_eq(func1, func3, invert=True)
assertion.function_eq(func1, func4, invert=True)
assertion.function_eq(func1, None, exception=TypeError)


def test_any() -> None:
"""Test :meth:`AssertionManager.any`."""
assertion.any([True, True, False])
Expand Down

0 comments on commit 80aa712

Please sign in to comment.