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 |
46 |
47 if qualName == "requests" and context.callFunctionName in httpVerbs: |
|
48 # check for missing timeout |
|
49 if context.checkCallArgValue("timeout") is None: |
|
50 reportError( |
|
51 context.node.lineno - 1, |
|
52 context.node.col_offset, |
|
53 "S114.1", |
|
54 "M", |
|
55 "L", |
|
56 qualName, |
|
57 ) |
|
58 |
|
59 if ( |
47 if ( |
60 qualName == "requests" |
48 qualName == "requests" |
61 and context.callFunctionName in httpVerbs |
49 and context.callFunctionName in httpVerbs |
62 or qualName == "httpx" |
50 and context.checkCallArgValue("timeout") is None |
63 and context.callFunctionName in httpxAttrs |
|
64 ): |
51 ): |
|
52 # check for missing timeout |
|
53 reportError( |
|
54 context.node.lineno - 1, |
|
55 context.node.col_offset, |
|
56 "S114.1", |
|
57 "M", |
|
58 "L", |
|
59 qualName, |
|
60 ) |
|
61 |
|
62 if ( |
|
63 (qualName == "requests" and context.callFunctionName in httpVerbs) |
|
64 or (qualName == "httpx" and context.callFunctionName in httpxAttrs) |
|
65 ) and context.checkCallArgValue("timeout", "None"): |
65 # check for timeout=None |
66 # check for timeout=None |
66 if context.checkCallArgValue("timeout", "None"): |
67 reportError( |
67 reportError( |
68 context.node.lineno - 1, |
68 context.node.lineno - 1, |
69 context.node.col_offset, |
69 context.node.col_offset, |
70 "S114.2", |
70 "S114.2", |
71 "M", |
71 "M", |
72 "L", |
72 "L", |
73 qualName, |
73 qualName, |
74 ) |
74 ) |
|