flake8 plugin that checks for missing `timeout` parameters in network calls.
Project description
flake8-timeout
A flake8 plugin that checks for missing timeout parameters in network calls.
By default, the plugin checks common HTTP libraries but can be configured to track any function that accepts a timeout parameter.
installation
pip install flake8-timeout
flake8 code
| Code | Description |
|---|---|
| TIM100 | timeout missing for request call |
default tracked functions
The plugin tracks these functions by default:
requests.getrequests.postrequests.putrequests.deleterequests.headrequests.patchrequests.optionsrequests.requesturllib.request.urlopen(timeout at positional index 2)
configuration
as a pre-commit hook
See pre-commit for instructions
Sample .pre-commit-config.yaml:
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-timeout==2.0.0]
extending the defaults
Use --timeout-extend-funcs to add custom functions while keeping the defaults:
Command line:
flake8 --timeout-extend-funcs=my_http_lib.request,custom.api.call:1
Pre-commit:
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-timeout==2.0.0]
args: [--timeout-extend-funcs=my_http_lib.request,custom.api.call:1]
This will check the defaults plus your custom functions.
overriding the defaults
Use --timeout-funcs to replace the defaults entirely:
Command line:
flake8 --timeout-funcs=custom.http.get,custom.http.post:2
Pre-commit:
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-timeout==2.0.0]
args: [--timeout-funcs=custom.http.get,custom.http.post:2]
This will only check the functions you specify, ignoring the defaults.
positional timeout arguments
Some functions accept timeout as a positional argument. Specify the 0-based index after a colon:
my_lib.fetch:2 # timeout is at index 2 (3rd argument)
other.call:0 # timeout is at index 0 (1st argument)
Example with positional timeout:
# my_lib.fetch(url, data, timeout)
my_lib.fetch('https://api.example.com', None, 30) # OK - timeout at index 2
my_lib.fetch('https://api.example.com', None) # TIM100 - missing timeout
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flake8_timeout-2.0.0.tar.gz.
File metadata
- Download URL: flake8_timeout-2.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27dd5e0cc0e424e03ade6652949e7cfb9badad7404e50e60d6bb29cffd75ee22
|
|
| MD5 |
0fceaae4ae1d173ed032dd52a3fa5910
|
|
| BLAKE2b-256 |
9a40a958614169b63f57b0eb7f4d6a8f5ae7ab45e3d8400b3ec7f45258268a34
|
File details
Details for the file flake8_timeout-2.0.0-py2.py3-none-any.whl.
File metadata
- Download URL: flake8_timeout-2.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed8cd50dd5ee556d32d4efed2ab750218600abe81da1b99a8dbec57becf965bb
|
|
| MD5 |
5e543a4ee3c8a190304882708e739715
|
|
| BLAKE2b-256 |
1a46d8130db12ff5a17aada5bf915679ff39b2ff8c47fe41429dbb80ca9db964
|