Use raw strings for docstrings with forward slashes#816
Merged
Conversation
A few docstrings in `bot.cogs.extensions` have forward slashed in them to escape Markdown rendering when our help feature uses these docstring in a Discord message. However, the use of forward slashes with an invalid escape sequence in docstrings now raises a DeprecationWarning in Python: /home/sebastiaan/pydis/repositories/bot/bot/cogs/extensions.py:72: DeprecationWarning: invalid escape sequence \* PEP 257 (Docstring Conventions, https://www.python.org/dev/peps/pep-0257/) states that raw strings should be used for docstrings that use forward slashes, so I've added the `r`-prefix to the docstrings that use forward slashes.
sco1
approved these changes
Mar 4, 2020
ikuyarihS
approved these changes
Mar 4, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A few docstrings in
bot.cogs.extensionsuse forward slashed to escape Markdown rendering when the docstrings are used in our bot's help feature. However, forward slashes are also interpreted as escape sequences in Python and since these ones are not valid, they will now raise aDeprecationWarning:PEP 257 -- Docstring Conventions specifies that you should use raw strings whenever a docstring contains forward slashes:
So that's what I did; I turned those docstrings into raw strings.
Note: The
DeprecationWarningwill only show up when the code is compiled to bytecode (i.e., when the compiler is involved). Once the module is compiled to bytecode and saved as a.pyc, the warning will no longer show up until you clean__pycache__and/or make changes to the file forcing it to be recompiled.