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: Fix Python 3.8 type error #3615

Merged
merged 3 commits into from
Sep 3, 2024

Conversation

szokeasaurusrex
Copy link
Contributor

@szokeasaurusrex szokeasaurusrex commented Sep 3, 2024

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

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

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

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:

  • Fix a type error in Python 3.8 by converting a type hint to a string to prevent runtime evaluation.

@szokeasaurusrex
Copy link
Contributor Author

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

Copy link
Contributor

sourcery-ai bot commented Sep 3, 2024

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:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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 @szokeasaurusrex - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a test case to verify this fix works as expected across different Python versions, particularly 3.8 and above.
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 to tell me if it was helpful.

@botberry
Copy link
Member

botberry commented Sep 3, 2024

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
Copy link
Member

botberry commented Sep 3, 2024

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)

Copy link

codspeed-hq bot commented Sep 3, 2024

CodSpeed Performance Report

Merging #3615 will not alter performance

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

Summary

✅ 15 untouched benchmarks

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@           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
Copy link
Member

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

I'll add a release and ship this 😊

@patrick91 patrick91 merged commit 50baec9 into strawberry-graphql:main Sep 3, 2024
110 of 111 checks passed
@botberry
Copy link
Member

botberry commented Sep 3, 2024

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 🔥

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.

TypeError in Python 3.8 (regression)
3 participants