Repository: bluesky/bluesky
Pull request #1705 (2024-04-16 12:16:32)

(#1650) promotes warn_if_msg to a UserWarning
* utils module API function warn_if_msg_args_or_kwargs is hereby promoted from PendingDeprecationWarning

<!--- Provide a general summary of your changes in the Title above -->

## Description
Promotes warning type to raise visibility from tests only
to every day coding

## Motivation and Context
Prior to this change, the warning it provides 
would only show up in tests ( and therefore in practice be ignored )

## How Has This Been Tested?
It hasn't yet - but the existing Utils module test
was updated to accommodate the change of warning type.
(Full testing is beyond the scope of the change)
Testing will happen when future code changes hit the new warning 
and it is visible

<!--
## Screenshots (if appropriate):
-->



Patch:
diff --git a/src/bluesky/utils/__init__.py b/src/bluesky/utils/__init__.py
index 76502d53..c3734608 100644
--- a/src/bluesky/utils/__init__.py
+++ b/src/bluesky/utils/__init__.py
@@ -17,7 +17,18 @@ from collections import namedtuple
 from collections.abc import Iterable
 from functools import partial, reduce, wraps
 from inspect import Parameter, Signature
-from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, List, Optional, Tuple, Type, Union
+from typing import (
+    Any,
+    AsyncIterable,
+    AsyncIterator,
+    Callable,
+    Dict,
+    List,
+    Optional,
+    Tuple,
+    Type,
+    Union,
+)
 from weakref import WeakKeyDictionary, ref
 
 import msgpack
@@ -65,7 +76,9 @@ class Msg(namedtuple("Msg_base", ["command", "obj", "args", "kwargs", "run"])):
     __slots__ = ()
 
     def __new__(cls, command, obj=None, *args, run=None, **kwargs):
-        return super(Msg, cls).__new__(cls, command, obj, args, kwargs, run)  # noqa: UP008
+        return super(Msg, cls).__new__(  # noqa: UP008
+            cls, command, obj, args, kwargs, run
+        )
 
     def __repr__(self):
         return (
@@ -861,7 +874,12 @@ SEARCH_PATH = []
 ENV_VAR = "BLUESKY_HISTORY_PATH"
 if ENV_VAR in os.environ:
     SEARCH_PATH.append(os.environ[ENV_VAR])
-SEARCH_PATH.extend([os.path.expanduser("~/.config/bluesky/bluesky_history.db"), "/etc/bluesky/bluesky_history.db"])
+SEARCH_PATH.extend(
+    [
+        os.path.expanduser("~/.config/bluesky/bluesky_history.db"),
+        "/etc/bluesky/bluesky_history.db",
+    ]
+)
 
 
 def get_history():
@@ -1340,7 +1358,12 @@ class TerminalProgressBar(ProgressBarBase):
             # cases differ from the naive computaiton performed by
             # format_meter.
             meter = tqdm.format_meter(
-                n=n, total=total, elapsed=time_elapsed, unit=unit, prefix=name, ncols=self.ncols
+                n=n,
+                total=total,
+                elapsed=time_elapsed,
+                unit=unit,
+                prefix=name,
+                ncols=self.ncols,
             )
         else:
             # Simply display completeness.
@@ -1566,7 +1589,10 @@ def merge_cycler(cyc):
             raise ValueError("Passed in a mix of real and pseudo axis. Can not cope, failing")
         pseudo_axes = type_map["pseudo"]
         if len(pseudo_axes) > 1:
-            p_cyc = reduce(operator.add, (cycler(my_name(c), input_data[c]) for c in type_map["pseudo"]))
+            p_cyc = reduce(
+                operator.add,
+                (cycler(my_name(c), input_data[c]) for c in type_map["pseudo"]),
+            )
             output_data.append(cycler(parent, list(p_cyc)))
         elif len(pseudo_axes) == 1:
             (c,) = pseudo_axes
@@ -1848,7 +1874,7 @@ In the future the passing of Msg.args and Msg.kwargs down to hardware from
 Msg("{msg.command}") may be deprecated. If you have a use case for these,
 we would like to know about it, so please open an issue at
 https://github.com/bluesky/bluesky/issues"""
-        warnings.warn(error_msg, PendingDeprecationWarning)  # noqa: B028
+        warnings.warn(error_msg)  # noqa: B028
 
 
 def maybe_update_hints(hints: Dict[str, Hints], obj):


Test patch:
diff --git a/src/bluesky/tests/test_utils.py b/src/bluesky/tests/test_utils.py
index 03e9961c..05072708 100644
--- a/src/bluesky/tests/test_utils.py
+++ b/src/bluesky/tests/test_utils.py
@@ -115,7 +115,13 @@ def test_cycler_merge_mixed(hw, children):
 
 
 def test_is_movable(hw):
-    obj_list = [(10, False), (1.05, False), ("some_string", False), (hw.det, False), (hw.motor, True)]
+    obj_list = [
+        (10, False),
+        (1.05, False),
+        ("some_string", False),
+        (hw.det, False),
+        (hw.motor, True),
+    ]
     for obj, result in obj_list:
         assert is_movable(obj) == result, (
             f"The object {obj} is incorrectly recognized " f"as {'' if result else 'not '}movable"
@@ -482,7 +488,7 @@ def test_msg_args_kwargs_emits_warning_first_time(recwarn):
     assert len(recwarn) == 0
     warn_if_msg_args_or_kwargs(msg, device.kickoff, (), {"arg": "value"})
     assert len(recwarn) == 1
-    w = recwarn.pop(PendingDeprecationWarning)
+    w = recwarn.pop(UserWarning)
     assert (
         str(w.message)
         == """\