diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 402bdfc9fb7..46a67b4ea3a 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -496,10 +496,12 @@ def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str] sig_prefix = self.get_signature_prefix(sig) if sig_prefix: if type(sig_prefix) is str: - logger.warning( - "Python directive get_signature_prefix() returns a str ('{}')" - " instead of a list of nodes (changed in 4.3).".format(sig_prefix), - location=signode) + warnings.warn( + "Python directive method get_signature_prefix()" + " returning a string is deprecated." + " It must now return a list of nodes." + " Return value was '{}'.".format(sig_prefix), + RemovedInSphinx50Warning) signode += addnodes.desc_annotation(sig_prefix, '', # type: ignore nodes.Text(sig_prefix)) # type: ignore else: