strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations 🍓
https://strawberry.rocks
MIT License
3.95k stars 525 forks source link

fix: Fix Python 3.8 type error #3615

Closed szokeasaurusrex closed 4 weeks ago

szokeasaurusrex commented 4 weeks ago

Description

Make type hint a string so that it is not evaluated at runtime, where it would cause a TypeError in Python 3.8.

Types of Changes

Issues Fixed or Closed by This PR

Checklist

Summary by Sourcery

Fix a type error in Python 3.8 by converting a type hint to a string in the async_base_view.py file.

Bug Fixes:

szokeasaurusrex commented 4 weeks ago

I am not sure how to add a test here/whether it is needed

sourcery-ai[bot] commented 4 weeks ago

Reviewer's Guide by Sourcery

This pull request fixes a Python 3.8 type error by modifying a type hint in the strawberry/http/async_base_view.py file. The change involves making the type hint a string to prevent it from being evaluated at runtime, which was causing a TypeError in Python 3.8.

File-Level Changes

Change Details Files
Modified type hint to prevent runtime evaluation
  • Changed queue = asyncio.Queue[Tuple[bool, Any]](1) to queue: "asyncio.Queue[Tuple[bool, Any]]" = asyncio.Queue(1)
  • Wrapped the type hint in quotes to make it a string
strawberry/http/async_base_view.py

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
botberry commented 4 weeks ago

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release fixes a TypeError on Python 3.8 due to us using a asyncio.Queue[Tuple[bool, Any]](1) instead of asyncio.Queue(1).

Here's the tweet text:

🆕 Release (next) is out! Thanks to Daniel Szoke for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)
botberry commented 4 weeks ago

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 Daniel Szoke for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)
codspeed-hq[bot] commented 4 weeks ago

CodSpeed Performance Report

Merging #3615 will not alter performance

Comparing szokeasaurusrex:main (022b6ef) with main (54b8a49)

Summary

✅ 15 untouched benchmarks

codecov[bot] commented 4 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.79%. Comparing base (54b8a49) to head (022b6ef). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3615 +/- ## ======================================= Coverage 96.79% 96.79% ======================================= Files 517 517 Lines 33530 33530 Branches 5576 5576 ======================================= Hits 32454 32454 Misses 848 848 Partials 228 228 ```
patrick91 commented 4 weeks ago

@szokeasaurusrex thanks! I wonder why this wasn't caught in our CI 🤔

I'll add a release and ship this 😊

botberry commented 4 weeks ago

Thanks for contributing to Strawberry! 🎉 You've been invited to join the Strawberry GraphQL organisation 😊

You can also request a free sticker by filling this form: https://forms.gle/dmnfQUPoY5gZbVT67

And don't forget to join our discord server: https://strawberry.rocks/discord 🔥