- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Show the repr of the value in some warnings. #10439
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, although this probably needs a CHANGES entry.
Where else were you thinking of changing from str
-> repr
?
A
I've seen a few more that seem related by looking for sphinx/sphinx/domains/citation.py Lines 30 to 32 in 1222bed
Lines 40 to 42 in 1222bed
Searching for Searching for Line 171 in 1222bed
and several others (some even use '...: "%s".' % value ), but I'm not sure if these are related, since I'm not too familiar with the codebase.
I only fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I commented at #10438 (comment), these target can contain a single quote. So -0 for changing this.
Python's >>> print(repr(""" "only double quotes" """)) # output uses single quotes
' "only double quotes" '
>>> print(repr(""" 'only single quotes' """)) # output uses double quotes
" 'only single quotes' "
>>> print(repr(""" "mixed" 'quotes' """)) # output uses single quotes + escapes
' "mixed" \'quotes\' ' Therefore, with the changes in my PR, the following markup: :ref:`Documenting Python <invalidlabel>`
:ref:`in-development <in"dev"branch>`
:ref:`maintenance <maint'branch>`
:ref:`Quick Guide to Pull Requests <pull"request"-quick'guide>`
:doc:`pull request <pull'request>`
:ref:`contributor agreement < cla>`
:doc:`pull request <pullrequest >` will trigger these warnings:
Only the fourth example (that contains both single and double quotes) includes an escaped For comparison, without using the
Note that it's difficult to notice the extra spaces in the last two examples (especially in the last one). |
@ezio-melotti please add a CHANGES entry. A |
Thanks for taking care of the CHANGES entry and merging this! |
Subject: Show the repr of the value in some warnings
Feature or Bugfix
Purpose
%r
to display values in some warning messages.Detail
Note that I only fixed
sphinx/domains/std.py
and the tests that failed after the fix.There are similar warnings in other files that could be changed.
A test specific for trailing spaces could be added, but I'm not sure where.