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

Commit

Permalink
Remove D302, redundant now Python 2 is dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Aug 31, 2020
1 parent 2cca069 commit d62c3c0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 35 deletions.
25 changes: 1 addition & 24 deletions src/pydocstyle/checker.py
Expand Up @@ -385,23 +385,6 @@ def check_backslashes(self, definition, docstring):
and not docstring.startswith(('r', 'ur'))):
return violations.D301()

@check_for(Definition)
def check_unicode_docstring(self, definition, docstring):
r'''D302: Use u""" for docstrings with Unicode.
For Unicode docstrings, use u"""Unicode triple-quoted strings""".
'''
if 'unicode_literals' in definition.module.future_imports:
return

# Just check that docstring is unicode, check_triple_double_quotes
# ensures the correct quotes.
if docstring and sys.version_info[0] <= 2:
if not is_ascii(docstring) and not docstring.startswith(
('u', 'ur')):
return violations.D302()

@staticmethod
def _check_ends_with(docstring, chars, violation):
"""First line ends with one of `chars`.
Expand Down Expand Up @@ -453,13 +436,7 @@ def check_imperative_mood(self, function, docstring): # def context
if check_word in IMPERATIVE_BLACKLIST:
return violations.D401b(first_word)

try:
correct_forms = IMPERATIVE_VERBS.get(stem(check_word))
except UnicodeDecodeError:
# This is raised when the docstring contains unicode
# characters in the first word, but is not a unicode
# string. In which case D302 will be reported. Ignoring.
return
correct_forms = IMPERATIVE_VERBS.get(stem(check_word))

if correct_forms and check_word not in correct_forms:
best = max(
Expand Down
2 changes: 1 addition & 1 deletion src/pydocstyle/violations.py
Expand Up @@ -214,7 +214,7 @@ def to_rst(cls) -> str:
D300 = D3xx.create_error('D300', 'Use """triple double quotes"""',
'found {0}-quotes')
D301 = D3xx.create_error('D301', 'Use r""" if any backslashes in a docstring')
D302 = D3xx.create_error('D302', 'Use u""" for Unicode docstrings')
D302 = D3xx.create_error('D302', 'Deprecated: Use u""" for Unicode docstrings')

D4xx = ErrorRegistry.create_group('D4', 'Docstring Content Issues')
D400 = D4xx.create_error('D400', 'First line should end with a period',
Expand Down
10 changes: 0 additions & 10 deletions src/tests/test_cases/test.py
Expand Up @@ -279,16 +279,6 @@ def exceptions_of_D301():
"""


if sys.version_info[0] <= 2:
@expect('D302: Use u""" for Unicode docstrings')
def unicode_unmarked():
"""Юникод."""

@expect('D302: Use u""" for Unicode docstrings')
def first_word_has_unicode_byte():
"""あy."""


@expect("D400: First line should end with a period (not 'y')")
@expect("D415: First line should end with a period, question mark, "
"or exclamation point (not 'y')")
Expand Down

0 comments on commit d62c3c0

Please sign in to comment.