Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 6039dc6

Browse files
committed
Allow docstrings given as raw unicode (ur""")
1 parent f7fad8c commit 6039dc6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pep257.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,12 @@ def check_triple_double_quotes(self, definition, docstring):
996996
997997
'''
998998
if docstring and '"""' in eval(docstring) and docstring.startswith(
999-
("'''", "r'''", "u'''")):
999+
("'''", "r'''", "u'''", "ur'''")):
10001000
# Allow ''' quotes if docstring contains """, because otherwise """
10011001
# quotes could not be expressed inside docstring. Not in PEP 257.
10021002
return
1003-
if docstring and not docstring.startswith(('"""', 'r"""', 'u"""')):
1003+
if docstring and not docstring.startswith(
1004+
('"""', 'r"""', 'u"""', 'ur"""')):
10041005
quotes = "'''" if "'''" in docstring[:4] else "'"
10051006
return D300(quotes)
10061007

@@ -1014,7 +1015,8 @@ def check_backslashes(self, definition, docstring):
10141015
'''
10151016
# Just check that docstring is raw, check_triple_double_quotes
10161017
# ensures the correct quotes.
1017-
if docstring and '\\' in docstring and not docstring.startswith('r'):
1018+
if docstring and '\\' in docstring and not docstring.startswith(
1019+
('r', 'ur')):
10181020
return D301()
10191021

10201022
@check_for(Definition)
@@ -1027,7 +1029,8 @@ def check_unicode_docstring(self, definition, docstring):
10271029
# Just check that docstring is unicode, check_triple_double_quotes
10281030
# ensures the correct quotes.
10291031
if docstring and sys.version_info[0] <= 2:
1030-
if not is_ascii(docstring) and not docstring.startswith('u'):
1032+
if not is_ascii(docstring) and not docstring.startswith(
1033+
('u', 'ur')):
10311034
return D302()
10321035

10331036
@check_for(Definition)

0 commit comments

Comments
 (0)