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

Use explicit response code to avoid type error #3666

Merged

Conversation

DoctorJohn
Copy link
Member

@DoctorJohn DoctorJohn commented Oct 10, 2024

Description

This PR removes an unneeded type: ignore I just stumbled upon and couldn't get out of my head.

Types of Changes

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

Summary by Sourcery

Refactor the Flask integration's render_graphql_ide method to use explicit response parameters, improving type safety and removing an unnecessary type: ignore comment. Document the change in a new RELEASE.md file.

Enhancements:

  • Refactor the render_graphql_ide method in the Flask integration to use an explicit response code and content type, removing the need for a type: ignore comment.

Documentation:

  • Add a RELEASE.md file to document the patch release, highlighting the stricter typing in the Flask integration.

Copy link
Contributor

sourcery-ai bot commented Oct 10, 2024

Reviewer's Guide by Sourcery

This pull request enhances the Flask integration in the Strawberry GraphQL library by improving type safety and removing an unnecessary type ignore comment. The changes focus on the render_graphql_ide method, making it more explicitly typed and returning a properly constructed Response object.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Refactor render_graphql_ide method to return an explicit Response object
  • Remove type ignore comment
  • Store rendered template in a variable
  • Return a Response object with explicit status code and content type
strawberry/flask/views.py
Add release notes for the change
  • Specify release type as patch
  • Describe the change as an improvement to type checking in Flask integration
RELEASE.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.
  • 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 - here's some feedback:

Overall Comments:

  • Good job on improving type safety and removing the type: ignore comment. Consider bundling this change with other minor improvements in a future release rather than creating a separate patch release, unless there are other unreleased changes that would justify a new version.
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: 1 issue found

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.

RELEASE.md Outdated Show resolved Hide resolved
@botberry
Copy link
Member

botberry commented Oct 10, 2024

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release tweaks the Flask integration's render_graphql_ide method to be stricter typed internally, making type checkers ever so slightly happier.

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

codecov bot commented Oct 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.01%. Comparing base (daec236) to head (f2bc322).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3666      +/-   ##
==========================================
+ Coverage   96.67%   97.01%   +0.34%     
==========================================
  Files         503      503              
  Lines       33457    33458       +1     
  Branches     5602     5618      +16     
==========================================
+ Hits        32343    32460     +117     
+ Misses        880      792      -88     
+ Partials      234      206      -28     

Copy link

codspeed-hq bot commented Oct 12, 2024

CodSpeed Performance Report

Merging #3666 will not alter performance

Comparing DoctorJohn:fix-flask-return-type (f2bc322) with main (daec236)

Summary

✅ 15 untouched benchmarks

@DoctorJohn DoctorJohn merged commit 153da5e into strawberry-graphql:main Oct 12, 2024
109 checks passed
@DoctorJohn DoctorJohn deleted the fix-flask-return-type branch October 12, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants