Skip to content

Update#221

Merged
xtsea merged 8 commits intomainfrom
dev
Apr 2, 2026
Merged

Update#221
xtsea merged 8 commits intomainfrom
dev

Conversation

@xtsea
Copy link
Copy Markdown
Contributor

@xtsea xtsea commented Apr 2, 2026

Summary by Sourcery

Introduce a new request execution API and convenience completion method.

New Features:

  • Add a Request.execute API with create, run, get, and delete helpers for request lifecycle management.
  • Expose the new Request helper on the main client for easy access to request execution operations.
  • Add a done() convenience method on RequestCall to return either raw results, success status, or parsed data based on flags.

Documentation:

  • Update the changelog with a new version entry describing the added request execution helpers and done/skip methods.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 2, 2026

Reviewer's Guide

Introduces a new request execution API (tg.request.execute) with helper methods and a convenience done() wrapper on RequestCall, wires it into the client surface, and documents the additions in the changelog.

Sequence diagram for tg.request.execute.create() with RequestCall.done

sequenceDiagram
    actor UserCode
    participant Client
    participant Request
    participant Execute
    participant RequestCall
    participant HTTPAPI

    UserCode->>Client: client.request.execute.create(data)
    Client->>Request: request
    Request->>Execute: execute
    Execute->>RequestCall: create(**kw)
    Activate RequestCall

    UserCode->>RequestCall: done(ok=true, dot=false)
    RequestCall->>HTTPAPI: execute()
    HTTPAPI-->>RequestCall: { ok, data }

    alt ok flag set
        alt response ok and has data
            RequestCall-->>UserCode: result.ok (bool)
        else response not ok or missing data
            RequestCall-->>UserCode: None
        end
    end

    deactivate RequestCall
Loading

Class diagram for new tg.request.execute API and RequestCall.done

classDiagram
    class Client {
        +CustomTranslate translate
        +Services services
        +Quotes quotes
        +Request request
        +DefaultMethod use
        +Platform platform
        +MediaFactory media
    }

    class Request {
        +Execute execute
        +__init__(client)
    }

    class Execute {
        +__init__(client)
        +create(**kw)
        +run(**kw)
        +get(request_id)
        +delete(request_id)
    }

    class RequestCall {
        +_client
        +_method
        +_path
        +_params
        +execute()
        +skip()
        +done(ok, dot)
        +json()
    }

    Client --> Request : has
    Request --> Execute : has
    Execute --> RequestCall : creates
    RequestCall --> Client : uses _client
Loading

File-Level Changes

Change Details Files
Add a convenience result-handling helper method on RequestCall.
  • Introduce async done(ok=False, dot=False) that delegates to execute() and returns either a boolean success flag, a ResponseResult object, or the raw response based on flags.
  • Reuses the existing execute() behavior and response schema to avoid duplicating request logic.
tgcore/core.py
Expose a new request execution surface on the client.
  • Instantiate a Request façade on the main client object and assign it to self.request so that downstream code can access request-related helpers via tg.request.
  • Ensure Request is initialized alongside other top-level client feature groups like services and quotes.
tgcore/client.py
Introduce Execute and Request helper classes for request execution endpoints.
  • Create an Execute BaseMethod subclass that produces RequestCall objects for create, run, get, and delete operations against the /api/v3/request endpoints.
  • Provide a Request container class whose execute attribute exposes the Execute helper, forming the tg.request.execute.* API.
tgcore/execute/__init__.py
Document the new request execution helpers and convenience methods in the changelog.
  • Add version 1.0.97 section describing new tg.request.execute.create(), run(), get(), delete(), and the addition of .done() and .skip() helpers.
CHANGELOG.md

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

Copy link
Copy Markdown
Contributor

@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 - I've left some high level feedback:

  • In Execute.run the function signature uses **KW but the body references request_id and kw, which are undefined; adjust the parameters and variable names so the request ID and payload are passed in correctly.
  • The new Request helper added to tgcore/client.py is instantiated (self.request = Request(self)) but the Request class from tgcore.execute is never imported, which will cause a NameError at runtime.
  • The done method signature in core.py uses dot=False while the changelog describes .done(ok=False, result=False); align the parameter name and behavior with the documented interface to avoid confusion for callers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `Execute.run` the function signature uses `**KW` but the body references `request_id` and `kw`, which are undefined; adjust the parameters and variable names so the request ID and payload are passed in correctly.
- The new `Request` helper added to `tgcore/client.py` is instantiated (`self.request = Request(self)`) but the `Request` class from `tgcore.execute` is never imported, which will cause a `NameError` at runtime.
- The `done` method signature in `core.py` uses `dot=False` while the changelog describes `.done(ok=False, result=False)`; align the parameter name and behavior with the documented interface to avoid confusion for callers.

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.

@xtsea xtsea merged commit e638363 into main Apr 2, 2026
5 checks passed
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