来自 AWS Lambda Powertools 的 @validator 装饰器的 Pylint 错误 Python

Pylint errors with @validator decorator from AWS Lambda Powertools Python

我在使用 Lambda Powertools for Python. If I download the three files from the Validator decorator example code 和 运行 pylint --errors-only validator_decorator.py 时遇到了一些 Pylint 错误,我遇到了三个错误:

************* Module validator_decorator
validator_decorator.py:5:1: E1120: No value for argument 'handler' in function call (no-value-for-parameter)
validator_decorator.py:5:1: E1120: No value for argument 'event' in function call (no-value-for-parameter)
validator_decorator.py:5:1: E1120: No value for argument 'context' in function call (no-value-for-parameter)

这是来自 validator_decorator.py 的代码:

from aws_lambda_powertools.utilities.validation import validator

import schemas

@validator(inbound_schema=schemas.INPUT, outbound_schema=schemas.OUTPUT)
def handler(event, context):
    return event

尽管有错误,代码工作正常,但我想知道我是否做错了什么。我总是可以添加一个 # pylint: disable=no-value-for-parameter,但如果有更好的方法来处理这个问题,我宁愿不添加。我已经尝试挖掘 the source but there's a lot of wrapping going on there, and since I'm at the level of just having read Primer on Python Decorators 我可以帮助理解这一点。谢谢。

(venv) $ python --version
Python 3.9.10
(venv) $ pylint --version
pylint 2.12.2
astroid 2.9.3
Python 3.9.10 (main, Jan 15 2022, 11:40:53) 
[Clang 13.0.0 (clang-1300.0.29.3)]

查看函数文档here if you click "expand source code",其中一个使用建议是这样的:

from aws_lambda_powertools.utilities.validation import validate

def handler(event, context):
    validate(event=event, schema=json_schema_dict)
    return event

还有其他建议,但不是用作装饰器的地方,也许它不应该用作装饰器。