-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Remove requests dependency from ClientTransaction class #270
base: main
Are you sure you want to change the base?
Conversation
- Remove requests import and type hints - Modify validate_response to handle BeautifulSoup only
Reviewer's Guide by SourceryThis PR removes the No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
WalkthroughThe changes in the pull request primarily focus on the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Hey @WXL-steven - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
twikit/x_client_transaction/transaction.py (2)
58-61
: Improve error message clarityThe error message could be more descriptive to help with debugging.
- raise Exception("invalid response") + raise TypeError(f"Expected bs4.BeautifulSoup object, got {type(response).__name__}")
Line range hint
1-180
: Review migration progress to httpxThe changes are moving in the right direction with the simplification of
validate_response
. However, to complete the migration from requests to httpx:
- The
get_indices
method still contains requests-specific code that needs to be reviewed for httpx compatibility- Consider documenting the expected response interface (perhaps with a Protocol) to ensure compatibility across HTTP clients
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
twikit/x_client_transaction/transaction.py
(1 hunks)
🔇 Additional comments (1)
twikit/x_client_transaction/transaction.py (1)
Line range hint 42-43
: Verify httpx compatibility in get_indices method
The method assumes the response has a .text
attribute which is requests-specific. When migrating to httpx, ensure the response object provides compatible access to the response text.
Changes
This PR removes the
requests
dependency from the ClientTransaction class as part of the migration tohttpx
. The changes are minimal and focused on maintaining compatibility while removing unused code.What's Changed
requests
import and its type hints from validate_responseBeautifulSoup
objects only__main__
blockTesting
The changes are minimal and only affect type hints and input validation. Since only init() and generate_transaction_id() methods are used in production, and they already use the async session, this change should not affect existing functionality.
Notes
requests
tohttpx
Summary by Sourcery
Enhancements:
Summary by CodeRabbit
New Features
Bug Fixes
BeautifulSoup
objects, improving reliability.Refactor