Skip to content

Commit f45900b

Browse files
committed
remove deprecation utility, favor pydeprecate (https://pypi.org/project/pyDeprecate/)
1 parent c9c0f35 commit f45900b

File tree

3 files changed

+4
-43
lines changed

3 files changed

+4
-43
lines changed

environment.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies:
1616
- logical-unification
1717
- miniKanren
1818
- cons
19+
- pydeprecate
1920
# Intel BLAS
2021
- mkl
2122
- mkl-service
@@ -49,3 +50,4 @@ dependencies:
4950
# optional
5051
- sympy
5152
- cython
53+

pytensor/utils.py

+1-43
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
"""Utility functions that only depend on the standard library."""
22

33
import hashlib
4-
import inspect
54
import logging
65
import os
76
import struct
87
import subprocess
98
import sys
10-
import traceback
11-
import warnings
129
from collections import OrderedDict
1310
from collections.abc import Callable
14-
from functools import partial, wraps
11+
from functools import partial
1512
from typing import List, Set
1613

1714

1815
__all__ = [
1916
"get_unbound_function",
2017
"maybe_add_to_os_environ_pathlist",
2118
"DefaultOrderedDict",
22-
"deprecated",
2319
"subprocess_Popen",
2420
"call_subprocess_Popen",
2521
"output_subprocess_Popen",
@@ -140,44 +136,6 @@ def maybe_add_to_os_environ_pathlist(var, newpath):
140136
pass
141137

142138

143-
def deprecated(message: str = ""):
144-
"""
145-
This is a decorator which can be used to mark functions
146-
as deprecated. It will result in a warning being emitted
147-
when the function is used first time and filter is set for show DeprecationWarning.
148-
149-
Taken from https://stackoverflow.com/a/40899499/4473230
150-
"""
151-
152-
def decorator_wrapper(func):
153-
@wraps(func)
154-
def function_wrapper(*args, **kwargs):
155-
nonlocal message
156-
157-
current_call_source = "|".join(
158-
traceback.format_stack(inspect.currentframe())
159-
)
160-
if current_call_source not in function_wrapper.last_call_source:
161-
162-
if not message:
163-
message = f"Function {func.__name__} is deprecated."
164-
165-
warnings.warn(
166-
message,
167-
category=DeprecationWarning,
168-
stacklevel=2,
169-
)
170-
function_wrapper.last_call_source.add(current_call_source)
171-
172-
return func(*args, **kwargs)
173-
174-
function_wrapper.last_call_source = set()
175-
176-
return function_wrapper
177-
178-
return decorator_wrapper
179-
180-
181139
def subprocess_Popen(command, **params):
182140
"""
183141
Utility function to work around windows behavior that open windows.

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ install_requires =
5353
miniKanren
5454
cons
5555
typing_extensions
56+
pydeprecate
5657
setuptools >=48.0.0
5758

5859
[options.packages.find]

0 commit comments

Comments
 (0)