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

Fix TypeError with bytes docstrings #570

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pydocstyle/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,13 @@ def check_one_liners(self, definition, docstring):

"""
if docstring:
lines = ast.literal_eval(docstring).split('\n')
docstring_text = ast.literal_eval(docstring)
if isinstance(docstring_text, bytes):
# bytes objects are not valid docstrings.
return

lines = docstring_text.split('\n')

if len(lines) > 1:
non_empty_lines = sum(1 for l in lines if not is_blank(l))
if non_empty_lines == 1:
Expand Down