Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update deprecations #177

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from .util import * # noqa: F401, F403

# Deprecated
# isort: split
from .parametric import Val # noqa: F401, F403
from .util import multihash # noqa: F401, F403

# Ensure that type checking is always entirely correct! The default O(1) strategy
Expand Down
11 changes: 3 additions & 8 deletions plum/parametric.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import contextlib
import warnings
from typing import Type, TypeVar, Union

from typing_extensions import deprecated

import beartype.door
from beartype.roar import BeartypeDoorNonpepException

Expand All @@ -19,7 +20,6 @@
"type_unparametrized",
"kind",
"Kind",
"Val",
]

T = TypeVar("T")
Expand Down Expand Up @@ -632,6 +632,7 @@ def get(self):
Kind = kind() #: A default kind provided for convenience.


@deprecated("Use `typing.Literal[val]` instead.")
@parametric
class Val:
"""A parametric type used to move information from the value domain to the type
Expand Down Expand Up @@ -661,12 +662,6 @@ def __init__(self, val=None):
Args:
val (object): The value to be moved to the type domain.
"""
warnings.warn(
"`plum.Val` is deprecated and will be removed in a future version. "
"Please use `typing.Literal` instead.",
category=DeprecationWarning,
stacklevel=2,
)
if type(self).concrete:
if val is not None and type_parameter(self) != val:
raise ValueError("The value must be equal to the type parameter.")
Expand Down
10 changes: 3 additions & 7 deletions plum/util.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import abc
import sys
import warnings
from typing import Hashable, List, Sequence

from typing_extensions import deprecated

if sys.version_info.minor <= 8: # pragma: specific no cover 3.9 3.10 3.11
from typing import Callable
else: # pragma: specific no cover 3.8
Expand Down Expand Up @@ -47,6 +48,7 @@ def __init__(self):
raise TypeError("`Missing` cannot be instantiated.")


@deprecated("Use `hash(tuple_of_args)` instead.")
def multihash(*args: Hashable) -> int:
"""Multi-argument order-sensitive hash.

Expand All @@ -56,12 +58,6 @@ def multihash(*args: Hashable) -> int:
Returns:
int: Hash.
"""
warnings.warn(
"The function `multihash` is deprecated and will be removed in a future "
"version. Please use `hash(tuple(*args))` instead.",
DeprecationWarning,
stacklevel=2,
)
return hash(args)


Expand Down
Loading