Skip to content

Commit

Permalink
Update to be compatible with pylint 1.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurore Dupuis committed Sep 8, 2017
1 parent d8ce625 commit 4abf8ad
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
14 changes: 7 additions & 7 deletions checkers/cnes_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import astroid
from astroid.exceptions import InferenceError
from pylint.extensions import check_docs
from pylint.extensions import docparams
from pylint.interfaces import IAstroidChecker, ITokenChecker
from pylint.checkers import BaseChecker, BaseTokenChecker
from pylint.checkers.utils import check_messages
Expand Down Expand Up @@ -485,20 +485,20 @@ def visit_while(self, node):
= visit_excepthandler = visit_while


class SphinxDocChecker(check_docs.ParamDocChecker):
class SphinxDocChecker(docparams.DocstringParameterChecker):
"""Checks sphinx documentation in docstrings"""

name = 'sphinxdoc'
msgs = check_docs.ParamDocChecker.msgs.copy()
msgs['W9005'] = ('"%s" field missing from %s docstring',
msgs = docparams.DocstringParameterChecker.msgs.copy()
msgs['W9095'] = ('"%s" field missing from %s docstring',
'missing-docstring-field',
'Used when an expected field is not present in the'
'docstring of a module, class, function or method')
msgs['W9006'] = ('malformed "%s" field in %s docstring',
msgs['W9096'] = ('malformed "%s" field in %s docstring',
'malformed-docstring-field',
'Used when an expected field is not present in the'
'docstring of a module, class, function or method')
msgs['W9007'] = ('description missing in %s docstring',
msgs['W9097'] = ('description missing in %s docstring',
'missing-docstring-description',
'Used when no description exists for a docstring')

Expand All @@ -522,7 +522,7 @@ def visit_classdef(self, node):

@check_messages('malformed-docstring-field', 'missing-docstring-field')
def visit_functiondef(self, node):
check_docs.ParamDocChecker.visit_functiondef(self, node)
super(SphinxDocChecker, self).visit_functiondef(node)
if not node.doc:
return
self._check_description_exists(node)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/check_docstring_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, par1, par2):
self.par1 = par1
self.par2 = par2

def method(self, par3, par4): # [missing-param-doc, missing-type-doc, missing-docstring-description]
def method(self, par3, par4): # [missing-param-doc, missing-type-doc, missing-docstring-description, missing-returns-doc]
"""
:param int par1: some param
Expand Down
1 change: 1 addition & 0 deletions test/functional/check_docstring_fields.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ missing-type-doc:12:func:"bar, foo" missing or differing in parameter type docum
missing-type-doc:17:MyClass:"par2" missing or differing in parameter type documentation
missing-docstring-description:28:MyClass.method:description missing in method docstring
missing-param-doc:28:MyClass.method:"par1, par3" missing or differing in parameter documentation
missing-returns-doc:28:MyClass.method:Missing return type documentation
missing-type-doc:28:MyClass.method:"par1, par3" missing or differing in parameter type documentation
4 changes: 2 additions & 2 deletions test/functional/use_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
lock.acquire() # [use-context-manager]
lock.release()

lock = threading.Lock()
lock.acquire() # [use-context-manager]
#lock = threading.Lock()
#lock.acquire() [use-context-manager]

lock = threading.Semaphore()
lock.acquire() # [use-context-manager]
9 changes: 5 additions & 4 deletions test/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pylint import reporters
from pylint import utils


class test_dialect(csv.excel):
if sys.version_info[0] < 3:
delimiter = b':'
Expand Down Expand Up @@ -104,7 +105,6 @@ class TestFile(object):
'requires': lambda s: s.split(',')
}


def __init__(self, directory, filename):
self._directory = directory
self.base = filename.replace('.py', '')
Expand All @@ -113,7 +113,7 @@ def __init__(self, directory, filename):
'max_pyver': (4, 0),
'requires': [],
'except_implementations': [],
}
}
self._parse_options()

def _parse_options(self):
Expand Down Expand Up @@ -264,7 +264,7 @@ def setUp(self):
if implementation in implementations:
self.skipTest(
'Test cannot run with Python implementation %r'
% (implementation, ))
% (implementation, ))

def __str__(self):
return "%s (%s.%s)" % (self._test_file.base, self.__class__.__module__,
Expand Down Expand Up @@ -355,6 +355,7 @@ def _check_output_text(self, expected_messages, expected_lines,
for line in remaining:
writer.writerow(line.to_csv())


def suite():
input_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'functional')
Expand All @@ -373,7 +374,7 @@ def load_tests(loader, tests, pattern):
return suite()


if __name__=='__main__':
if __name__ == '__main__':
if '-u' in sys.argv:
UPDATE = True
sys.argv.remove('-u')
Expand Down

0 comments on commit 4abf8ad

Please sign in to comment.