Skip to content

Commit e631823

Browse files
committed
Add-doc
1 parent 15134dc commit e631823

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
requests.post("http://localhost") # [missing-timeout]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"timeout" parameter is recommended in order to stop waiting for a call after a given number with the timeout parameter.
2+
3+
See the following requests_timeouts_ documentation:
4+
5+
- *Nearly all production code should use this parameter in nearly all requests. Failure to do so can cause your program to hang indefinitely*
6+
7+
8+
Predefined Methods With Timeout
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
Pylint provides set of predefined method with timeout. Those predefined
11+
methods may be changed to add new ones from Pylint configuration.
12+
13+
Following predefined methods are available:
14+
15+
* ``requests.api.get``
16+
* ``requests.api.head``
17+
* ``requests.api.options``
18+
* ``requests.api.patch``
19+
* ``requests.api.post``
20+
* ``requests.api.put``
21+
* ``requests.api.request``
22+
23+
Following option is exposed:
24+
25+
.. option:: --timeout-methods=<library.method>
26+
27+
28+
You can add new methods in your Pylint configuration
29+
using the pylint ``qname`` of the method
30+
31+
You can get it using the following code:
32+
33+
.. code:: python
34+
35+
from astroid import extract_node
36+
node = extract_node('from requests import get;get()')
37+
print(next(node.func.infer()).qname())
38+
39+
And the library needs to be installed in order to be detected
40+
41+
You can add the following possible cases ``timeout-methods``:
42+
43+
* ``http.client.HTTPConnection``
44+
* ``http.client.HTTPSConnection``
45+
* ``serial.serialcli.Serial``
46+
* ``smtplib.SMTP``
47+
* ``suds.client.Client``
48+
* ``urllib.request.urlopen``
49+
50+
.. _requests_timeouts: https://requests.readthedocs.io/en/latest/user/quickstart/#timeouts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
requests.post("http://localhost", timeout=10)

0 commit comments

Comments
 (0)