Skip to content

Commit

Permalink
Show the actual line for DeprecationWarning
Browse files Browse the repository at this point in the history
By default, a call to 'warnings.warn()' will mention the line where that
call is performed.
Being a library, our goal is to point to the user code provoking the
DeprecationWarning - using stacklevel=2 to refer to the caller of the
'use_strategy' function.
  • Loading branch information
rbarrois committed Dec 28, 2020
1 parent 178f816 commit 8a9b148
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions factory/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ def use_strategy(new_strategy):
warnings.warn(
"use_strategy() is deprecated and will be removed in the future.",
DeprecationWarning,
stacklevel=2,
)

def wrapped_class(klass):
Expand Down

0 comments on commit 8a9b148

Please sign in to comment.