Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fallback for changed get_signature_prefix() #9833

Merged
merged 3 commits into from Nov 10, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion sphinx/domains/python.py
Expand Up @@ -495,7 +495,15 @@ def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str]

sig_prefix = self.get_signature_prefix(sig)
if sig_prefix:
signode += addnodes.desc_annotation(str(sig_prefix), '', *sig_prefix)
if type(sig_prefix) is str:
logger.warning(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use warnings.warn() instead? It can describe what version this fallback will be dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Removed in v5 or v6?
Is there a way to automatically attach the location that triggered this? (the location=signode that logger.warning() accepts)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our deprecation policy is "the deprecated feature will work during 2 MAJOR releases at least". So it will be removed in v6.0.
https://www.sphinx-doc.org/en/master/internals/release-process.html#deprecation-policy

Is there a way to automatically attach the location that triggered this?

No way to do that. It would be nice if we can improve it in the future.

"Python directive get_signature_prefix() returns a str ('{}')"
" instead of a list of nodes (changed in 4.3).".format(sig_prefix),
location=signode)
signode += addnodes.desc_annotation(sig_prefix, '', # type: ignore
nodes.Text(sig_prefix)) # type: ignore
else:
signode += addnodes.desc_annotation(str(sig_prefix), '', *sig_prefix)

if prefix:
signode += addnodes.desc_addname(prefix, prefix)
Expand Down