Skip to content

Commit bb6439a

Browse files
authored
Updates after review
1 parent 7cb07c6 commit bb6439a

File tree

2 files changed

+2
-60
lines changed

2 files changed

+2
-60
lines changed
Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
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-
You can reproduce the issue using deelay.me
8-
9-
.. code:: python
10-
11-
import requests
12-
response = requests.get("https://deelay.me/5000/http://localhost:80") # It will spend 5s
13-
14-
response = requests.get("https://deelay.me/5000/http://localhost:80", timeout=2) # timeout
15-
16-
response = requests.get("https://deelay.me/1000/http://localhost:80", timeout=2) # fine
17-
18-
19-
Now try to use a bigger delay value as ``https://deelay.me/1000000``
20-
21-
22-
Predefined Methods With Timeout
23-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24-
Pylint provides set of predefined method with timeout. Those predefined
25-
methods may be changed to add new ones from Pylint configuration.
26-
27-
Following predefined methods are available:
1+
You can add new methods that should have a defined ```timeout`` argument as qualified names
2+
in the ``timeout-methods`` options, for example:
283

294
* ``requests.api.get``
305
* ``requests.api.head``
@@ -33,32 +8,3 @@ Following predefined methods are available:
338
* ``requests.api.post``
349
* ``requests.api.put``
3510
* ``requests.api.request``
36-
37-
Following option is exposed:
38-
39-
.. option:: --timeout-methods=<library.method>
40-
41-
42-
You can add new methods in your Pylint configuration
43-
using the pylint ``qname`` of the method
44-
45-
You can get it using the following code:
46-
47-
.. code:: python
48-
49-
from astroid import extract_node
50-
node = extract_node('from requests import get;get()')
51-
print(next(node.func.infer()).qname())
52-
53-
And the library needs to be installed in order to be detected
54-
55-
You can add the following possible cases ``timeout-methods``:
56-
57-
* ``http.client.HTTPConnection``
58-
* ``http.client.HTTPSConnection``
59-
* ``serial.serialcli.Serial``
60-
* ``smtplib.SMTP``
61-
* ``suds.client.Client``
62-
* ``urllib.request.urlopen``
63-
64-
.. _requests_timeouts: https://requests.readthedocs.io/en/latest/user/quickstart/#timeouts

pylint/checkers/method_args.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ class MethodArgsChecker(BaseChecker):
3333
"in order to avoid waiting for a long time. If no timeout "
3434
"is specified explicitly the default value is used, for example "
3535
"for 'requests' the program will never time out (i.e. hang indefinitely). "
36-
"Notice the libraries needs to be installed and the name should be the output of pylint infered. "
37-
"from astroid import extract_node;"
38-
"node = extract_node('from requests import get;get()');"
39-
"print(next(node.func.infer()).qname())",
4036
),
4137
}
4238
options = (

0 commit comments

Comments
 (0)