Skip to content

feat: “About this account” support to fetch account-based-in location from X#398

Open
vicliv wants to merge 1 commit intod60:mainfrom
vicliv:about-page
Open

feat: “About this account” support to fetch account-based-in location from X#398
vicliv wants to merge 1 commit intod60:mainfrom
vicliv:about-page

Conversation

@vicliv
Copy link
Copy Markdown

@vicliv vicliv commented Nov 26, 2025

Adds support for Twitter's "about this account" feature. Returns account region, location accuracy, username change history, and verification status. Document new usage and provide an example script showing retrieval of the “account based in” location from X.

Summary by Sourcery

Add support for retrieving and representing Twitter/X "About this account" metadata for users, including exposure via both authenticated and guest clients and basic documentation and example usage.

New Features:

  • Introduce an AccountAbout data model for Twitter/X "About this account" metadata, including location, username history, and verification fields.
  • Expose a get_about method on User and GuestUser to fetch the "About this account" information for a given user.
  • Add client and guest client methods to call the AboutAccount GraphQL endpoint and return AccountAbout objects.
  • Document how to fetch "About this account" information and provide an example script demonstrating retrieval of the account-based-in location.

Enhancements:

  • Extend GraphQL endpoint constants and feature flags to support the AboutAccount query.

Summary by CodeRabbit

  • New Features

    • Added functionality to retrieve and display user account information, including location and verification status details.
  • Documentation

    • Added example script demonstrating account information retrieval.
    • Updated README with code examples for the new feature.

✏️ Tip: You can customize this high-level summary in your review settings.

…About data, allows to new get location based from X.
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Nov 26, 2025

Reviewer's Guide

Implements support for Twitter/X’s “About this account” GraphQL endpoint by introducing an AccountAbout model, wiring new client and guest-client methods to call the new GQL query, exposing convenient User/GuestUser helpers, and documenting usage with an example script and README snippet.

Sequence diagram for get_user_about flow via guest client

sequenceDiagram
    actor Developer
    participant Script as ExampleScript
    participant GuestClient
    participant GqlClient
    participant TwitterAPI as Twitter_GraphQL_Endpoint
    participant AccountAbout

    Developer->>Script: run about_account.py
    Script->>GuestClient: get_user_about("sama")
    GuestClient->>GqlClient: about_account("sama")
    GqlClient->>TwitterAPI: gql_get(ABOUT_ACCOUNT, variables, ABOUT_ACCOUNT_FEATURES)
    TwitterAPI-->>GqlClient: GraphQL response data
    GqlClient-->>GuestClient: (response, guest_token)
    GuestClient->>GuestClient: extract user_result_by_screen_name
    GuestClient->>GuestClient: validate result or raise error
    GuestClient->>AccountAbout: __init__(user_data)
    AccountAbout-->>GuestClient: AccountAbout instance
    GuestClient-->>Script: AccountAbout instance
    Script->>Script: access account_based_in, username_changes, is_identity_verified
    Script-->>Developer: display about-account info
Loading

Class diagram for AccountAbout and new about-account API surface

classDiagram
    class AccountAbout {
        +str id
        +str rest_id
        +str screen_name
        +str name
        +str account_based_in
        +bool location_accurate
        +str affiliate_username
        +str source
        +int username_changes
        +int username_last_changed_at
        +bool is_identity_verified
        +int verified_since_msec
        +__init__(data) AccountAbout
        +_to_int(value) int
        +__repr__() str
    }

    class Client {
        +get_user_by_screen_name(screen_name) User
        +get_user_about(screen_name) AccountAbout
    }

    class GuestClient {
        +get_user_by_screen_name(screen_name) User
        +get_user_about(screen_name) AccountAbout
    }

    class GqlClient {
        +user_by_screen_name(screen_name)
        +user_by_rest_id(user_id)
        +about_account(screen_name)
    }

    class User {
        -Client _client
        +str id
        +str screen_name
        +get_tweets(tweet_type, count) list
        +get_about() AccountAbout
    }

    class GuestUser {
        -GuestClient _client
        +str id
        +str screen_name
        +get_tweets(tweet_type, count) list
        +get_about() AccountAbout
    }

    class Endpoint {
        <<enumeration>>
        +USER_BY_SCREEN_NAME
        +USER_BY_REST_ID
        +ABOUT_ACCOUNT
    }

    class Constants {
        <<static>>
        +ABOUT_ACCOUNT_FEATURES
    }

    Client --> GqlClient : uses
    GuestClient --> GqlClient : uses

    Client ..> AccountAbout : creates
    GuestClient ..> AccountAbout : creates

    User --> Client : holds
    GuestUser --> GuestClient : holds

    User ..> AccountAbout : returns from get_about
    GuestUser ..> AccountAbout : returns from get_about

    GqlClient ..> Endpoint : uses
    GqlClient ..> Constants : uses ABOUT_ACCOUNT_FEATURES
Loading

File-Level Changes

Change Details Files
Add AccountAbout data model to represent "About this account" response payloads.
  • Introduce AccountAbout class with attributes for account region, location accuracy, username change metadata, and verification info.
  • Parse nested about_profile, core, and verification_info fields from the GraphQL user payload with defensive .get usage.
  • Normalize numeric-like fields via a helper _to_int method and implement a concise repr for debugging.
twikit/user.py
Expose high-level API on User and GuestUser to fetch "About this account" for a user.
  • Add async get_about method on User that delegates to the client’s get_user_about with the user’s screen_name.
  • Add async get_about method on guest.user.User mirroring the main User API, delegating to GuestClient.get_user_about.
twikit/user.py
twikit/guest/user.py
Add client- and guest-client-level methods to call the new AboutAccount GraphQL endpoint.
  • Define Endpoint.ABOUT_ACCOUNT URL and ABOUT_ACCOUNT_FEATURES feature set for the new query.
  • Implement Client.get_user_about and GuestClient.get_user_about that call gql.about_account, validate the response, handle UserNotFound and UserUnavailable, and wrap the result in AccountAbout.
  • Implement Gql.about_account to perform the underlying GraphQL GET with the correct variables and features.
twikit/client/client.py
twikit/guest/client.py
twikit/client/gql.py
twikit/constants.py
Document and demonstrate usage of the new "About this account" functionality.
  • Extend README with a short example showing client.get_user_about and printing account_based_in and username_changes.
  • Add a runnable example script under examples/about_account.py that logs in a guest client, fetches About info for a username, and prints key fields.
README.md
examples/about_account.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 26, 2025

Walkthrough

A new feature for fetching account information is implemented. New get_user_about() methods are added to Client and GuestClient classes, with a corresponding AccountAbout data class created to represent the response. Associated GraphQL endpoint, feature flags, and a get_about() convenience method on User instances are included, along with documentation and examples.

Changes

Cohort / File(s) Change Summary
Core data class and public API
twikit/user.py, twikit/__init__.py
New AccountAbout class added to represent account information with fields like account_based_in, username_changes, and is_identity_verified. Exported from main module.
Client-side implementation
twikit/client/client.py, twikit/client/gql.py
Added get_user_about(screen_name) async method to Client class. New GraphQL about_account() method and ABOUT_ACCOUNT endpoint added to GQLClient.
GraphQL features and constants
twikit/constants.py
New ABOUT_ACCOUNT_FEATURES constant defining feature flags for the GraphQL query.
Guest client integration
twikit/guest/client.py, twikit/guest/user.py
Added get_user_about(screen_name) method to GuestClient. Added async get_about() convenience method to User class for fetching account information.
Documentation and examples
README.md, examples/about_account.py
Updated README with new feature reference. New example script demonstrates fetching and printing account information via guest client.

Sequence Diagram

sequenceDiagram
    participant User as User Code
    participant Client as Guest Client
    participant GQL as GQL Client
    participant API as Twitter API

    User->>Client: get_user_about(screen_name)
    Client->>GQL: about_account(screen_name)
    GQL->>API: GET about_account_endpoint
    API-->>GQL: JSON response
    GQL-->>Client: response data
    
    alt User not found
        Client-->>User: raise UserNotFound
    else Account unavailable
        Client-->>User: raise UserUnavailable
    else Success
        Client->>Client: Parse AccountAbout
        Client-->>User: return AccountAbout
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • AccountAbout class design: Verify proper field parsing, data validation, and the _to_int() helper implementation
  • Error handling flow: Confirm UserNotFound and UserUnavailable exceptions are raised appropriately in both Client and GuestClient
  • GraphQL integration: Review the new about_account() method, ABOUT_ACCOUNT endpoint URL, and ABOUT_ACCOUNT_FEATURES constant usage consistency
  • Async/await patterns: Ensure get_about() and get_user_about() methods correctly handle async calls across guest and standard clients

Poem

🐰 A curious cottontail hops through the code,
New AccountAbout fields on the developer's road,
GraphQL queries fetch what accounts conceal,
With get_about() methods, the truth they reveal,
Async hops and error checks—feature complete and spry! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.89% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding support for Twitter's 'About this account' feature to fetch account-based-in location. It aligns with the PR's primary objective and the core additions throughout the codebase.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • The get_user_about implementations in client.Client and guest.Client duplicate the same GraphQL call and error handling; consider extracting a shared helper to keep this logic in one place and reduce the chance of divergence.
  • In AccountAbout, fields like username_last_changed_at and verified_since_msec are exposed only as raw millisecond timestamps; consider adding convenience properties that return datetime objects for consistency with User.created_at_datetime.
  • User.get_about / GuestUser.get_about depend on self.screen_name; you might want to handle the case where screen_name is None or stale (e.g., by raising a clearer error or falling back to a rest_id-based lookup if that becomes available).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `get_user_about` implementations in `client.Client` and `guest.Client` duplicate the same GraphQL call and error handling; consider extracting a shared helper to keep this logic in one place and reduce the chance of divergence.
- In `AccountAbout`, fields like `username_last_changed_at` and `verified_since_msec` are exposed only as raw millisecond timestamps; consider adding convenience properties that return `datetime` objects for consistency with `User.created_at_datetime`.
- `User.get_about` / `GuestUser.get_about` depend on `self.screen_name`; you might want to handle the case where `screen_name` is `None` or stale (e.g., by raising a clearer error or falling back to a rest_id-based lookup if that becomes available).

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b18105 and 74f783f.

⛔ Files ignored due to path filters (36)
  • .DS_Store is excluded by !**/.DS_Store
  • twikit/.DS_Store is excluded by !**/.DS_Store
  • twikit/__pycache__/__init__.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/bookmark.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/community.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/constants.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/errors.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/geo.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/group.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/list.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/media.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/message.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/notification.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/streaming.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/trend.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/tweet.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/user.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/__pycache__/utils.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/_captcha/__pycache__/__init__.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/_captcha/__pycache__/base.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/_captcha/__pycache__/capsolver.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/client/__pycache__/client.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/client/__pycache__/gql.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/client/__pycache__/v11.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/guest/__pycache__/__init__.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/guest/__pycache__/client.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/guest/__pycache__/tweet.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/guest/__pycache__/user.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/ui_metrics/__pycache__/__init__.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/ui_metrics/__pycache__/dom.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/x_client_transaction/__pycache__/__init__.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/x_client_transaction/__pycache__/cubic_curve.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/x_client_transaction/__pycache__/interpolate.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/x_client_transaction/__pycache__/rotation.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/x_client_transaction/__pycache__/transaction.cpython-310.pyc is excluded by !**/*.pyc
  • twikit/x_client_transaction/__pycache__/utils.cpython-310.pyc is excluded by !**/*.pyc
📒 Files selected for processing (9)
  • README.md (1 hunks)
  • examples/about_account.py (1 hunks)
  • twikit/__init__.py (1 hunks)
  • twikit/client/client.py (2 hunks)
  • twikit/client/gql.py (3 hunks)
  • twikit/constants.py (1 hunks)
  • twikit/guest/client.py (2 hunks)
  • twikit/guest/user.py (2 hunks)
  • twikit/user.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
twikit/user.py (3)
twikit/client/client.py (2)
  • get (209-211)
  • get_user_about (1404-1425)
twikit/guest/client.py (2)
  • get (156-158)
  • get_user_about (234-255)
twikit/guest/user.py (1)
  • get_about (123-132)
twikit/guest/client.py (3)
twikit/errors.py (4)
  • UserNotFound (77-80)
  • UserUnavailable (82-85)
  • TwitterException (4-13)
  • Unauthorized (20-23)
twikit/client/client.py (3)
  • user (674-678)
  • get_user_about (1404-1425)
  • get (209-211)
twikit/user.py (1)
  • AccountAbout (17-80)
twikit/guest/user.py (3)
twikit/client/client.py (2)
  • user (674-678)
  • get_user_about (1404-1425)
twikit/user.py (2)
  • AccountAbout (17-80)
  • get_about (238-247)
twikit/guest/client.py (1)
  • get_user_about (234-255)
twikit/client/gql.py (1)
twikit/client/v11.py (1)
  • Endpoint (14-50)
twikit/__init__.py (1)
twikit/user.py (2)
  • AccountAbout (17-80)
  • User (83-598)
examples/about_account.py (2)
twikit/client/client.py (2)
  • user (674-678)
  • get_user_about (1404-1425)
twikit/guest/client.py (1)
  • get_user_about (234-255)
🪛 markdownlint-cli2 (0.18.1)
README.md

132-132: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🪛 Ruff (0.14.5)
twikit/guest/client.py

251-251: Avoid specifying long messages outside the exception class

(TRY003)

examples/about_account.py

7-7: Possible hardcoded password assigned to: "PASSWORD"

(S105)


14-14: Local variable client_user is assigned to but never used

Remove assignment to unused variable client_user

(F841)

twikit/client/client.py

1421-1421: Avoid specifying long messages outside the exception class

(TRY003)

🔇 Additional comments (10)
twikit/constants.py (1)

44-46: LGTM!

The new ABOUT_ACCOUNT_FEATURES constant follows the established pattern and is correctly defined for the about account GraphQL endpoint.

README.md (1)

132-136: LGTM!

The documentation example clearly demonstrates the new "About this account" feature usage and follows the existing README style.

twikit/__init__.py (1)

31-31: LGTM!

The public API correctly exports AccountAbout alongside User, making the new data class accessible to library users.

twikit/user.py (2)

17-80: LGTM!

The AccountAbout class is well-designed with:

  • Comprehensive docstring documenting all attributes
  • Safe data extraction using .get() with fallback to empty dicts
  • Robust _to_int helper that handles None and conversion errors gracefully
  • Proper __repr__ for debugging

238-247: LGTM!

The get_about method is correctly implemented as a convenience method that delegates to the client, following the same pattern as other User methods like get_tweets.

twikit/guest/user.py (1)

6-6: LGTM!

The import and get_about method are correctly implemented, maintaining consistency with the authenticated User class pattern.

Also applies to: 123-132

twikit/client/gql.py (1)

6-6: LGTM!

The GraphQL endpoint and method are correctly implemented:

  • Endpoint URL follows the established pattern
  • Method signature and implementation are consistent with similar methods like user_by_screen_name
  • Proper use of imported ABOUT_ACCOUNT_FEATURES

Also applies to: 43-43, 264-268

twikit/guest/client.py (2)

22-23: LGTM!

The necessary error types and AccountAbout class are correctly imported to support the new functionality.

Also applies to: 27-27


234-255: LGTM!

The get_user_about method is correctly implemented with:

  • Proper error handling for missing users and unavailable accounts
  • Safe nested dictionary access using .get() with fallback values
  • Consistent error messages that match the authenticated client implementation
  • Correct construction and return of AccountAbout instance

The implementation is identical to the authenticated Client.get_user_about method, ensuring consistency across both client types.

twikit/client/client.py (1)

49-49: I'm unable to access the repository to verify the AccountAbout class due to persistent clone failures. However, I can provide guidance based on the code context provided.

Verify AccountAbout class is properly defined and exported from the user module.

The import statement at line 49 follows the existing pattern and is syntactically correct. However, ensure that:

  • The AccountAbout class is defined in twikit/user.py and properly exported
  • The class includes all necessary fields for the "About this account" feature
  • The get_user_about() method at lines 1404-1426 correctly uses AccountAbout as the return type

These verifications should be confirmed through code review or integration testing.

Comment thread examples/about_account.py

async def main():
client.load_cookies('cookies.json')
client_user = await client.user()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove unused variable.

The client_user variable is fetched but never used. Consider either removing this line or using client_user.screen_name instead of the hardcoded 'sama' on line 16 to make the example more dynamic.

Apply this diff to remove the unused line:

-    client_user = await client.user()
-
     about = await client.get_user_about('sama')

Or alternatively, use the fetched user:

     client_user = await client.user()
-
-    about = await client.get_user_about('sama')
+    about = await client.get_user_about(client_user.screen_name)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Ruff (0.14.5)

14-14: Local variable client_user is assigned to but never used

Remove assignment to unused variable client_user

(F841)

🤖 Prompt for AI Agents
In examples/about_account.py around line 14, the variable client_user is
assigned but never used; either remove the unused line "client_user = await
client.user()" to eliminate dead code, or keep it and replace the hardcoded
'sama' on line 16 with client_user.screen_name so the example uses the fetched
user dynamically; ensure the await remains if you keep the call and update any
related code to reference client_user.screen_name.

Comment thread twikit/client/client.py
Comment on lines +1404 to +1426
async def get_user_about(self, screen_name: str) -> AccountAbout:
"""
Fetches "About this account" information by screen name.

Parameter
---------
screen_name : :class:`str`
The screen name of the Twitter user.

Returns
-------
:class:`AccountAbout`
A data object containing profile provenance details.
"""
response, _ = await self.gql.about_account(screen_name)
user_result = response.get('data', {}).get('user_result_by_screen_name')
if not user_result or 'result' not in user_result:
raise UserNotFound('The user does not exist.')
user_data = user_result['result']
if user_data.get('__typename') == 'UserUnavailable':
raise UserUnavailable(user_data.get('message'))
return AccountAbout(user_data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

Script executed:

#!/bin/bash
# First, find the client.py file and verify basic structure
fd -t f "client.py" | head -5

Repository: d60/twikit


<shell_result>
Repository: d60/twikit
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository d60/twikit: Clone operation failed
</shell_result>


twikit AccountAbout class documentation


<web_search_result>
Do you mean the Twikit "AccountAbout" class in their API/SDK (backend) or a component in the Twikit Design System (frontend)? I can search and fetch the official documentation — which would you like?
</web_search_result>


twikit Python SDK AccountAbout class gql about_account


<web_search_result>
I can help — do you want (pick one):

  • the twikit Python SDK docs or source for the AccountAbout class and the GraphQL query/mutation named about_account,
  • a short code example showing how to call a GraphQL about_account query using the twikit SDK (or using gql/httpx), or
  • help debugging an error you get when using AccountAbout/about_account?

Tell me which and I’ll fetch the exact docs/code.
</web_search_result>


twikit Python SDK AccountAbout class source code and gql about_account GraphQL query method documentation


<web_search_result>
I couldn't find an AccountAbout class or an about_account GraphQL method in the publicly available twikit docs/source I searched (twikit.readthedocs.io and related repos). Can you (please) tell me:

  • which repository or PyPI package name/version you mean (link if possible), or
  • paste the file or a small code excerpt you have?

With that I can fetch the exact source and the gql about_account documentation.
</web_search_result>


Based on the context provided, I can see that AccountAbout and gql.about_account are likely new additions in this PR being reviewed, which is why they're not in the public documentation yet. The code snippet itself demonstrates they exist and are being used.

Let me now assess the review comment on its merits:

Evaluating the Original Review Comment:

Given:

  1. The code snippet shows the method IS implemented (lines 1404-1426)
  2. The implementation uses AccountAbout(user_data) - indicating the class accepts user_data
  3. The method calls self.gql.about_account(screen_name) - indicating the gql method exists
  4. Proper error handling is in place
  5. The docstring has a typo: "Parameter" instead of "Parameters"

Conclusion:

The review comment makes valid suggestions for documentation improvements. However, the verification requests (checking if gql.about_account and AccountAbout exist) cannot be completed without direct repository access. Since the code is already shown to be implemented and integrated, these concerns are likely addressed.

The only verifiable issue is the docstring inconsistency ("Parameter" vs "Parameters"), which is a minor documentation fix.


Correct the docstring typo and consider adding examples for consistency.

The implementation is sound with proper error handling. One clear issue:

  • Line 1408: Change "Parameter" to "Parameters" to match standard NumPy docstring format

Consider also adding an Examples section if similar methods in the file use this pattern.

The review's verification requests about gql.about_account and AccountAbout cannot be confirmed without repository access, but the code shown indicates these are properly integrated.

🧰 Tools
🪛 Ruff (0.14.5)

1421-1421: Avoid specifying long messages outside the exception class

(TRY003)

🤖 Prompt for AI Agents
In twikit/client/client.py around lines 1404 to 1426, the docstring header uses
"Parameter" instead of the standard "Parameters"; change "Parameter" to
"Parameters" and, for consistency with other methods in this file, consider
adding an "Examples" section or aligning the docstring format to match the
project's NumPy-style docstrings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant