Skip to content

Commit

Permalink
Update for pydocstyle 2.0.0 compatibility
Browse files Browse the repository at this point in the history
Fix #96

Adding the newer ignore_decorators argument. Thanks to @not-raspberry for the tip!
  • Loading branch information
diraol committed Apr 20, 2017
1 parent 5ec2927 commit c08e6a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pylama/lint/pylama_pydocstyle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"""pydocstyle support."""

from pydocstyle import PEP257Checker
THIRD_ARG = True
try:
#: Import for pydocstyle 2.0.0 and newer
from pydocstyle import ConventionChecker as PyDocChecker
except ImportError:
#: Backward compatibility for pydocstyle prior to 2.0.0
from pydocstyle import PEP257Checker as PyDocChecker
THIRD_ARG = False

from pylama.lint import Linter as Abstract

Expand All @@ -15,11 +22,12 @@ def run(path, code=None, **meta):
:return list: List of errors.
"""
check_source_args = (code, path, None) if THIRD_ARG else (code, path)
return [{
'lnum': e.line,
# Remove colon after error code ("D403: ..." => "D403 ...").
'text': (e.message[0:4] + e.message[5:]
if e.message[4] == ':' else e.message),
'type': 'D',
'number': e.code
} for e in PEP257Checker().check_source(code, path)]
} for e in PyDocChecker().check_source(*check_source_args)]

0 comments on commit c08e6a2

Please sign in to comment.