Fix warning output

Warning filtering is the responsibility of the application, not a library, and this current use causes all warnings from an application (at least those after this function is evaluated the first time) to print their contents.

This makes the library a better citizen in the Python ecosystem, and more closely matches what developers would expect.

(For what it's worth, we also can't start using this library without this patch because the logging is too verbose and may obscure more important warnings. We depend on being able to accurately control warning and logging output)
This commit is contained in:
Dan Palmer 2018-05-30 14:50:22 +01:00 committed by GitHub
parent f13e54b4a4
commit 4e59cf3ea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,13 +6,11 @@ string_types = (type(b''), type(u''))
def warn_deprecation(text):
warnings.simplefilter('always', DeprecationWarning)
warnings.warn(
text,
category=DeprecationWarning,
stacklevel=2
)
warnings.simplefilter('default', DeprecationWarning)
def deprecated(reason):