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

Remove unused helpers and redundant overrides #3710

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

DoctorJohn
Copy link
Member

@DoctorJohn DoctorJohn commented Nov 22, 2024

Description

I noticed these helper methods are unused and their functionality is now part of the base views. While checking the other method in the __init__.py file, I noticed the FastAPI view needlessly overrides the process_result which is already defined in the exact same way by the async base view class.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Copy link
Contributor

sourcery-ai bot commented Nov 22, 2024

Reviewer's Guide by Sourcery

This PR removes unused helper functions and a redundant method override from the HTTP and FastAPI modules. The removed code includes helper methods for parsing query parameters and request data that are now handled by base views, as well as a redundant process_result override that was identical to its parent class implementation.

Updated class diagram for HTTP module

classDiagram
    class GraphQLRequestData {
        +String query
        +Dict variables
        +String operation_name
        +Literal protocol
    }

    class HTTPModule {
        -parse_query_params(params: Dict)
        -parse_request_data(data: Mapping)
    }

    GraphQLRequestData --> HTTPModule

    note for HTTPModule "Removed unused helper methods parse_query_params and parse_request_data"
Loading

Updated class diagram for FastAPI module

classDiagram
    class GraphQLRouter {
        +async render_graphql_ide(request: Request) HTMLResponse
        +async get_context(request: Union, response: Union) Context
        -async process_result(request: Request, result: ExecutionResult) GraphQLHTTPResponse
    }

    note for GraphQLRouter "Removed redundant process_result method override"
Loading

File-Level Changes

Change Details Files
Remove unused HTTP helper functions
  • Remove parse_query_params function that handled JSON parsing of variables
  • Remove parse_request_data function that converted raw data to GraphQLRequestData
  • Update all list to remove references to deleted functions
strawberry/http/__init__.py
Remove redundant method override in FastAPI router
  • Remove process_result method that was identical to the async base view implementation
  • Remove unused ExecutionResult import
strawberry/fastapi/router.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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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
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 @DoctorJohn - 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

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.

@botberry
Copy link
Member

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

Release type: patch

Description of the changes, ideally with some examples, if adding a new feature.

Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :)

Here's the tweet text:

🆕 Release (next) is out! Thanks to @NucleonJohn for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)

Copy link

codspeed-hq bot commented Nov 22, 2024

CodSpeed Performance Report

Merging #3710 will not alter performance

Comparing DoctorJohn:remove-unused-helpers (13c1871) with main (e4d4c99)

Summary

✅ 15 untouched benchmarks

@DoctorJohn DoctorJohn merged commit 8a41f87 into strawberry-graphql:main Nov 22, 2024
105 of 107 checks passed
@DoctorJohn DoctorJohn deleted the remove-unused-helpers branch November 22, 2024 15:37
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.56%. Comparing base (e4d4c99) to head (13c1871).
Report is 1 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (e4d4c99) and HEAD (13c1871). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (e4d4c99) HEAD (13c1871)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3710       +/-   ##
===========================================
- Coverage   97.02%   63.56%   -33.46%     
===========================================
  Files         500      496        -4     
  Lines       33483    32316     -1167     
  Branches     5593     1660     -3933     
===========================================
- Hits        32486    20541    -11945     
- Misses        793    11334    +10541     
- Partials      204      441      +237     
---- 🚨 Try these New Features:

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.

3 participants