通过创建HTTPStatus对象获取错误信息

时间:2018-07-06 20:50:49

标签: python http pylint

我正在尝试从代码中的http.HTTPStatus获取HTTP状态短语,因此基本上我正在执行以下操作:

http.HTTPStatus(code).phrase

它工作正常,但是当我在代码上运行pylint时,它失败并显示错误:

E: 60,14: No value for argument 'phrase' in constructor call (no-value-for-parameter)

http.HTTPStatus(来自Python来源)类如下所示:

class HTTPStatus(IntEnum):
"""HTTP status codes and reason phrases

Status codes from the following RFCs are all observed:

    * RFC 7231: Hypertext Transfer Protocol (HTTP/1.1), obsoletes 2616
    * RFC 6585: Additional HTTP Status Codes
    * RFC 3229: Delta encoding in HTTP
    * RFC 4918: HTTP Extensions for WebDAV, obsoletes 2518
    * RFC 5842: Binding Extensions to WebDAV
    * RFC 7238: Permanent Redirect
    * RFC 2295: Transparent Content Negotiation in HTTP
    * RFC 2774: An HTTP Extension Framework
"""
def __new__(cls, value, phrase, description=''):
    obj = int.__new__(cls, value)
    obj._value_ = value

    obj.phrase = phrase
    obj.description = description
    return obj
...

有什么提示吗?

谢谢

0 个答案:

没有答案