Я создаю новый класс проверки и добавляю предложения для печати, чтобы узнать время.Я думаю, что это не лучший способ, и я сделаю дальнейшее исследование
from pylint.checkers import BaseChecker
from pylint.interfaces import IAstroidChecker
class CustomTimeChecker(BaseChecker):
"""
find the check type in the following url:
https://github.com/PyCQA/pylint/blob/63eb8c4663a77d0caf2a842b716e4161f9763a16/pylint/checkers/typecheck.py
"""
print(begin)
__implements__ = IAstroidChecker
name = 'import-time-checker'
priority = -1
def __init__(self, linter):
super().__init__(linter)
print('test In samuel !')
def visit_importfrom(self, node):
end = datetime.datetime.now()
print('')
def visit_import(self, node):
)
def visit_attribute(self, node):
end = datetime.datetime.now()
print(' function Name '+str(node.name)+ ' takes the time for '+ str(end - self.begin))
def leave_functiondef(self, node):
end = datetime.datetime.now()
print(' function Name '+str(node.name)+ ' takes the time for '+ str(end - self.begin))
def leave_module(self, node):
"""
Actual checks are implemented here
"""
end = datetime.datetime.now()
print('Leaving the module ' + str(node.name) +' when the time is '+str(end - self.begin))
print('*'*40)
# print(node.name)
def visit_module(self, node):
end = datetime.datetime.now()
print('Entering the module ' + str(node.name) + ' when the time is' + str(end - self.begin))
def register(linter):
linter.register_checker(CustomTimeChecker(linter))