你可以自己写支票:
from pylint.interfaces import IRawChecker
from pylint.checkers import BaseChecker
class CopyrightChecker(BaseChecker):
""" Check the first line for copyright notice
"""
__implements__ = IRawChecker
name = 'custom_copy'
msgs = {'W9902': ('Include copyright in file',
'file-no-copyright',
('Your file has no copyright')),
}
options = ()
def process_module(self, node):
"""process a module
the module's content is accessible via node.stream() function
"""
with node.stream() as stream:
for (lineno, line) in enumerate(stream):
if lineno == 1:
self.add_message('file-no-copyright',
line=lineno)
def register(linter):
"""required method to auto register this checker"""
linter.register_checker(CopyrightChecker(linter))
查看有关自定义方格的详细信息
in the pylint documentation
. 阿尔索
this excellent post about the subject
.