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
Metadata
Release files for flake8_timeout 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flake8_timeout-2.0.0.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_timeout-2.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.2 kB
Release files / flake8_timeout-2.0.0.tar.gz
| Download URL | flake8_timeout-2.0.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27dd5e0cc0e424e03ade6652949e7cfb9badad7404e50e60d6bb29cffd75ee22
|
|
BLAKE2b-256 checksum How to use checksums |
9a40a958614169b63f57b0eb7f4d6a8f5ae7ab45e3d8400b3ec7f45258268a34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.13
|
Release files / flake8_timeout-2.0.0-py2.py3-none-any.whl
| Download URL | flake8_timeout-2.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ed8cd50dd5ee556d32d4efed2ab750218600abe81da1b99a8dbec57becf965bb
|
|
BLAKE2b-256 checksum How to use checksums |
1a46d8130db12ff5a17aada5bf915679ff39b2ff8c47fe41429dbb80ca9db964
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.13
|