From 4ef97b9d5c8a3a522b7ed07dc4a65d95e64947eb Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 25 May 2022 02:41:01 -0400 Subject: [PATCH] Remove newline from start of deprecation warnings This breaks the summary from Pytest when warnings are errors, as then you just get a bunch of: ``` FAILED lib/matplotlib/tests/test_getattr.py::test_getattr[matplotlib.afm] - matplotlib._api.deprecation.MatplotlibDeprecationWarning: ``` with no real context as to the problem. Also, as noted at the original PR [1], it makes setting `filterwarnings` more complicated. [1] https://github.com/matplotlib/matplotlib/pull/11224#issuecomment-435167674 --- lib/matplotlib/_api/deprecation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/_api/deprecation.py b/lib/matplotlib/_api/deprecation.py index 5c491e49772d..7c304173b2e5 100644 --- a/lib/matplotlib/_api/deprecation.py +++ b/lib/matplotlib/_api/deprecation.py @@ -32,7 +32,7 @@ def _generate_deprecation_warning( removal = f"in {removal}" if removal else "two minor releases later" if not message: message = ( - ("\nThe %(name)s %(obj_type)s" if obj_type else "%(name)s") + ("The %(name)s %(obj_type)s" if obj_type else "%(name)s") + (" will be deprecated in a future version" if pending else (" was deprecated in Matplotlib %(since)s"