38 @param context security context object |
38 @param context security context object |
39 @type SecurityContext |
39 @type SecurityContext |
40 @param _config dictionary with configuration data (unused) |
40 @param _config dictionary with configuration data (unused) |
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 qualName = context.callFunctionNameQual.split(".")[0] |
45 qualName = context.callFunctionNameQual.split(".")[0] |
45 if qualName == "requests" and context.callFunctionName in httpVerbs: |
46 if (qualName == "requests" and context.callFunctionName in httpVerbs) or ( |
|
47 qualName == "httpx" and context.callFunctionName in httpxAttrs |
|
48 ): |
46 # check for missing timeout |
49 # check for missing timeout |
47 if context.checkCallArgValue("timeout") is None: |
50 if context.checkCallArgValue("timeout") is None: |
48 reportError( |
51 reportError( |
49 context.node.lineno - 1, |
52 context.node.lineno - 1, |
50 context.node.col_offset, |
53 context.node.col_offset, |
51 "S114.1", |
54 "S114.1", |
52 "M", |
55 "M", |
53 "L", |
56 "L", |
|
57 qualName, |
54 ) |
58 ) |
55 |
59 |
56 # check for timeout=None |
60 # check for timeout=None |
57 if context.checkCallArgValue("timeout", "None"): |
61 if context.checkCallArgValue("timeout", "None"): |
58 reportError( |
62 reportError( |
59 context.node.lineno - 1, |
63 context.node.lineno - 1, |
60 context.node.col_offset, |
64 context.node.col_offset, |
61 "S114.2", |
65 "S114.2", |
62 "M", |
66 "M", |
63 "L", |
67 "L", |
|
68 qualName, |
64 ) |
69 ) |