Skip to content
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

fix(taps): Do not emit a warning needlessly when rest_method is not set in a stream class #2870

Conversation

edgarrmondragon
Copy link
Collaborator

@edgarrmondragon edgarrmondragon commented Feb 5, 2025

Related

Summary by Sourcery

Replace the deprecated rest_method property with http_method in REST and GraphQL streams.

Bug Fixes:

  • Resolve an issue where a warning was unnecessarily emitted when rest_method was not set in a stream class.

Enhancements:

  • Standardize the HTTP method property across REST and GraphQL streams.

Tests:

  • Update tests to reflect the change from rest_method to http_method.

📚 Documentation preview 📚: https://meltano-sdk--2870.org.readthedocs.build/en/2870/

@edgarrmondragon edgarrmondragon added the HTTP HTTP based taps and targets such (REST, XML, etc.) label Feb 5, 2025
Copy link
Contributor

sourcery-ai bot commented Feb 5, 2025

Reviewer's Guide by Sourcery

The pull request fixes an issue where a warning was unnecessarily emitted when rest_method was not set in a stream class. The implementation changes the logic for determining the HTTP method to use for requests, prioritizing http_method over the deprecated rest_method and only emitting a warning if rest_method is actually used.

Sequence diagram for HTTP method resolution in RESTStream

sequenceDiagram
    participant Client
    participant RESTStream

    Client->>RESTStream: Get HTTP method
    alt _http_method is set
        RESTStream-->>Client: Return _http_method
    else rest_method exists
        Note over RESTStream: Emit deprecation warning
        RESTStream-->>Client: Return rest_method
    else
        RESTStream-->>Client: Return default 'GET'
    end
Loading

Class diagram showing RESTStream and GraphQLStream changes

classDiagram
    class RESTStream {
        -_http_method: str
        +http_method(): str
        +set_http_method(value: str)
        +get_url(context: Context): str
    }

    class GraphQLStream {
        +path: str
        +http_method: str
        +records_jsonpath: str
    }

    GraphQLStream --|> RESTStream

    note for RESTStream "Removed deprecated rest_method property"
    note for GraphQLStream "Changed from rest_method to http_method"
Loading

File-Level Changes

Change Details Files
Modified the http_method property to handle the deprecated rest_method.
  • The http_method property now checks if self._http_method is set and returns it if it is.
  • If self._http_method is not set, it checks if rest_method exists as an attribute.
  • If rest_method exists, a deprecation warning is emitted, and the value of rest_method is returned.
  • If neither self._http_method nor rest_method is set, it defaults to "GET".
singer_sdk/streams/rest.py
Updated tests to reflect the changes in http_method and rest_method.
  • Added a test case to ensure that http_method returns "GET" when neither http_method nor rest_method is set.
  • Modified the test case for rest_method to check for a deprecation warning when rest_method is used.
  • Added a test case to set stream.http_method to None before setting stream.rest_method to "GET".
tests/core/test_streams.py
Replaced rest_method with http_method in GraphQLStream.
  • Changed the rest_method attribute to http_method and set it to "POST".
singer_sdk/streams/graphql.py

Possibly linked issues


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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.33%. Comparing base (1d00bfc) to head (28e4c17).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2870      +/-   ##
==========================================
- Coverage   91.34%   91.33%   -0.01%     
==========================================
  Files          62       62              
  Lines        5209     5203       -6     
  Branches      673      675       +2     
==========================================
- Hits         4758     4752       -6     
  Misses        319      319              
  Partials      132      132              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented Feb 5, 2025

CodSpeed Performance Report

Merging #2870 will not alter performance

Comparing edgarrmondragon/fix/do-not-emit-rest_method-warning-unnecessarily (28e4c17) with main (1d00bfc)

Summary

✅ 7 untouched benchmarks

@edgarrmondragon edgarrmondragon marked this pull request as ready for review February 5, 2025 15:55
@edgarrmondragon edgarrmondragon merged commit 61c1413 into main Feb 5, 2025
35 of 36 checks passed
@edgarrmondragon edgarrmondragon deleted the edgarrmondragon/fix/do-not-emit-rest_method-warning-unnecessarily branch February 5, 2025 15:56
Copy link
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 @edgarrmondragon - I've reviewed your changes - here's some feedback:

Overall Comments:

  • In the http_method getter, the condition checking for hasattr(self, "rest_method") might match both an instance‐set attribute and a lingering class property, which can be confusing. Consider checking the instance dictionary (e.g. using 'if "rest_method" in self.dict') to ensure you only warn when a deprecated instance attribute is set.
  • In the tests you first assert that the 'rest_method' attribute is absent, but then assign to it in a later scenario. Adding an inline comment explaining why it's intentionally re-added (to test backward compatibility and proper warning behavior) could improve clarity.
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

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.

@sourcery-ai sourcery-ai bot mentioned this pull request Feb 5, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTTP HTTP based taps and targets such (REST, XML, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Use http_method instead warning despite not declaring rest_method
1 participant