41 @type dict |
41 @type dict |
42 """ |
42 """ |
43 httpVerbs = {"get", "options", "head", "post", "put", "patch", "delete"} |
43 httpVerbs = {"get", "options", "head", "post", "put", "patch", "delete"} |
44 httpxAttrs = {"request", "stream", "Client", "AsyncClient"} | httpVerbs |
44 httpxAttrs = {"request", "stream", "Client", "AsyncClient"} | httpVerbs |
45 qualName = context.callFunctionNameQual.split(".")[0] |
45 qualName = context.callFunctionNameQual.split(".")[0] |
46 if (qualName == "requests" and context.callFunctionName in httpVerbs) or ( |
46 |
47 qualName == "httpx" and context.callFunctionName in httpxAttrs |
47 if qualName == "requests" and context.callFunctionName in httpVerbs: |
48 ): |
|
49 # check for missing timeout |
48 # check for missing timeout |
50 if context.checkCallArgValue("timeout") is None: |
49 if context.checkCallArgValue("timeout") is None: |
51 reportError( |
50 reportError( |
52 context.node.lineno - 1, |
51 context.node.lineno - 1, |
53 context.node.col_offset, |
52 context.node.col_offset, |
55 "M", |
54 "M", |
56 "L", |
55 "L", |
57 qualName, |
56 qualName, |
58 ) |
57 ) |
59 |
58 |
|
59 if ( |
|
60 qualName == "requests" |
|
61 and context.callFunctionName in httpVerbs |
|
62 or qualName == "httpx" |
|
63 and context.callFunctionName in httpxAttrs |
|
64 ): |
60 # check for timeout=None |
65 # check for timeout=None |
61 if context.checkCallArgValue("timeout", "None"): |
66 if context.checkCallArgValue("timeout", "None"): |
62 reportError( |
67 reportError( |
63 context.node.lineno - 1, |
68 context.node.lineno - 1, |
64 context.node.col_offset, |
69 context.node.col_offset, |