-
-
Notifications
You must be signed in to change notification settings - Fork 86
refactor(client): replace numeric duration values with datetime.timedelta
#454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the client API to use datetime.timedelta objects instead of numeric integer values (representing seconds) for all duration-related parameters. This affects both the Rust backend (which now uses std::time::Duration directly) and the Python frontend (which now accepts datetime.timedelta objects). The refactoring improves API clarity by making time units explicit and enables more precise duration specifications.
- Changed Rust type fields from
Option<u64>toOption<Duration>for all timeout, TCP keepalive, and pool idle timeout parameters - Updated Python type stubs to use
datetime.timedeltainstead ofintfor duration parameters - Removed
Duration::from_secsconversions in Rust code as Duration objects are now passed directly - Updated examples to demonstrate the new
datetime.timedeltausage
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/client/req.rs | Changed timeout and read_timeout fields from u64 to Duration; removed Duration::from_secs conversions |
| src/client.rs | Changed all timeout, TCP keepalive, and pool timeout fields from u64 to Duration; removed Duration::from_secs conversions |
| python/rnet/init.pyi | Updated type hints from int to datetime.timedelta for all duration parameters; includes unrelated changes (Message.json return type, formatting) |
| python/rnet/tls.py | Added str type support to KeyLog.file() path parameter (unrelated to main PR purpose) |
| python/examples/exceptions.py | Updated timeout usage to datetime.timedelta |
| python/examples/blocking/get.py | Updated timeout usage to datetime.timedelta |
| python/examples/orig_headers.py | Added null check for WebSocket message (unrelated to main PR purpose) |
| python/examples/keylog.py | Removed unused import (unrelated cleanup) |
| python/examples/blocking/proxy.py | Updated proxy usage to Proxy.all() (unrelated to main PR purpose) |
| python/examples/dns_override.py | Deleted file |
Comments suppressed due to low confidence (1)
python/examples/keylog.py:7
- The result of KeyLog.file is used even though it is always None.
client = Client(keylog=KeyLog.file("keylog.log"))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.