Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
5a5bf7ef
Unverified
Commit
5a5bf7ef
authored
Dec 01, 2022
by
Patrick von Platen
Committed by
GitHub
Dec 01, 2022
Browse files
[Deprecate] Correct stacklevel (#1483)
* Correct stacklevel * fix
parent
9276b1e1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
src/diffusers/utils/deprecation_utils.py
src/diffusers/utils/deprecation_utils.py
+1
-1
tests/test_utils.py
tests/test_utils.py
+6
-0
No files found.
src/diffusers/utils/deprecation_utils.py
View file @
5a5bf7ef
...
...
@@ -32,7 +32,7 @@ def deprecate(*args, take_from: Optional[Union[Dict, Any]] = None, standard_warn
if
warning
is
not
None
:
warning
=
warning
+
" "
if
standard_warn
else
""
warnings
.
warn
(
warning
+
message
,
FutureWarning
)
warnings
.
warn
(
warning
+
message
,
FutureWarning
,
stacklevel
=
2
)
if
isinstance
(
deprecated_kwargs
,
dict
)
and
len
(
deprecated_kwargs
)
>
0
:
call_frame
=
inspect
.
getouterframes
(
inspect
.
currentframe
())[
1
]
...
...
tests/test_utils.py
View file @
5a5bf7ef
...
...
@@ -162,3 +162,9 @@ class DeprecateTester(unittest.TestCase):
deprecate
((
"deprecated_arg"
,
self
.
higher_version
,
"This message is better!!!"
),
standard_warn
=
False
)
assert
str
(
warning
.
warning
)
==
"This message is better!!!"
def
test_deprecate_stacklevel
(
self
):
with
self
.
assertWarns
(
FutureWarning
)
as
warning
:
deprecate
((
"deprecated_arg"
,
self
.
higher_version
,
"This message is better!!!"
),
standard_warn
=
False
)
assert
str
(
warning
.
warning
)
==
"This message is better!!!"
assert
"diffusers/tests/test_utils.py"
in
warning
.
filename
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment