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 compatibility with starlette 0.18.0 and above #1594

Merged
merged 18 commits into from
May 19, 2022

Conversation

TimPansino
Copy link
Contributor

@TimPansino TimPansino commented Jan 25, 2022

Description

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).

@codecov
Copy link

codecov bot commented Jan 25, 2022

Codecov Report

Merging #1594 (10b411f) into main (35a627d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1594   +/-   ##
=======================================
  Coverage   98.04%   98.04%           
=======================================
  Files         143      143           
  Lines        5562     5564    +2     
  Branches     1023     1023           
=======================================
+ Hits         5453     5455    +2     
  Misses         56       56           
  Partials       53       53           

@TimPansino
Copy link
Contributor Author

All tests passed locally, looks like some tests failed on the runner though.

FAILED 😰  tests/asgi/test_http.py::test_returns_error_when_missing_query - a...
FAILED 😰  tests/asgi/test_http.py::test_returns_error_when_not_sending_wrong_content_type
FAILED 😰  tests/asgi/test_http.py::test_returns_error_when_method_is_not_allowed[PUT]
FAILED 😰  tests/asgi/test_http.py::test_returns_error_when_method_is_not_allowed[DELETE]
FAILED 😰  tests/asgi/test_query.py::test_fails_when_request_body_has_invalid_json
FAILED 😰  tests/asgi/test_view.py::test_renders_graphiql_disabled[/] - asser...
FAILED 😰  tests/asgi/test_view.py::test_renders_graphiql_disabled[/graphql]

@patrick91
Copy link
Member

All tests passed locally, looks like some tests failed on the runner though.

FAILED 😰  tests/asgi/test_http.py::test_returns_error_when_missing_query - a...
FAILED 😰  tests/asgi/test_http.py::test_returns_error_when_not_sending_wrong_content_type
FAILED 😰  tests/asgi/test_http.py::test_returns_error_when_method_is_not_allowed[PUT]
FAILED 😰  tests/asgi/test_http.py::test_returns_error_when_method_is_not_allowed[DELETE]
FAILED 😰  tests/asgi/test_query.py::test_fails_when_request_body_has_invalid_json
FAILED 😰  tests/asgi/test_view.py::test_renders_graphiql_disabled[/] - asser...
FAILED 😰  tests/asgi/test_view.py::test_renders_graphiql_disabled[/graphql]

Could be due to the different version of starlette on CI?

@TimPansino
Copy link
Contributor Author

@patrick91

  • I've fixed those failing tests on starlette versions 0.16, 0.17, and 0.18. The only tests that fail when I run locally are FastAPI for starlette 0.18, which those two are incompatible so that's not really a strawberry problem.
  • I updated pyproject.toml to reflect the new versions of starlette that should be supported.
  • I added the warning message for duplicate headers, needed an actual loop which is almost certainly slower but may be a better user experience.

Let me know if there are any other changes you want made to this PR.

If I may suggest something, your testing could be made much more thorough if you used a tool like tox or nox to test each of your compatibility layers with a matrix of package and python versions. Obviously that bloats testing times on actions but is much more thorough. If you have any interest feel free to check out https://github.com/newrelic/newrelic-python-agent for an example of how we use this for testing.

@patrick91
Copy link
Member

@patrick91

* I've fixed those failing tests on starlette versions 0.16, 0.17, and 0.18. The only tests that fail when I run locally are FastAPI for starlette 0.18, which those two are incompatible so that's not really a strawberry problem.

* I updated pyproject.toml to reflect the new versions of starlette that should be supported.

Awesome!

* I added the warning message for duplicate headers, needed an actual loop which is almost certainly slower but may be a better user experience.

Yes! Hopefully people won't have too many headers :D

Let me know if there are any other changes you want made to this PR.

I'll check it soon!

If I may suggest something, your testing could be made much more thorough if you used a tool like tox or nox to test each of your compatibility layers with a matrix of package and python versions. Obviously that bloats testing times on actions but is much more thorough. If you have any interest feel free to check out https://github.com/newrelic/newrelic-python-agent for an example of how we use this for testing.

We do something similar to this for django, but maybe tox is easier to use. Maybe we could mark the tests with pytest.mark.starlette and so on so we only test relevant tests when using the matrix?

@patrick91
Copy link
Member

I wonder how we can circumvent this issue with FastAPI not supporting the latest version of starlette 🤔

@patrick91
Copy link
Member

I guess we can wait for this PR to be merged and released 😊 fastapi/fastapi#4483

@patrick91
Copy link
Member

FastAPI is taking a long time to add support for latest starlette, so I think we should try to support both versions for a while :)

@Tushant
Copy link

Tushant commented May 6, 2022

latest starlette is now supported in fastapi.

@Kludex
Copy link
Member

Kludex commented May 6, 2022

latest starlette is now supported in fastapi.

it's not, latest starlette is 0.20.0... but starlette 0.18.0 is.

@krauss
Copy link

krauss commented May 10, 2022

Hey folks, do we have any news on this?

@AntonOfTheWoods
Copy link
Contributor

AntonOfTheWoods commented May 14, 2022

FastAPI 0.77.1 is out and supports starlette 0.19.1. Does that mean this PR needs an update?

EDIT: scratch that, now 0.78.0 is out. While there is still no support for starlette 0.20.0, are we certain that we need for the latest fastapi to support the latest starlette in order to move forward, particularly given that 0.20.0 appears to mainly drop python 3.6 support, and fastapi might not be happy to do that for a while longer?

@patrick91 it would be a shame for strawberry to start perpetual waiting like graphene did...

@patrick91
Copy link
Member

@AntonOfTheWoods I'll update this PR soon, I'm a bit busy these days 😊

pyproject.toml Outdated Show resolved Hide resolved
@patrick91 patrick91 marked this pull request as ready for review May 15, 2022 20:03
@patrick91
Copy link
Member

@Kludex does this PR look good to you? 😊

@botberry
Copy link
Member

botberry commented May 15, 2022

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release adds support for Starlette 0.18 to 0.20

It also removes upper bound dependencies limit for starlette,
allowing you to install the latest version without having to
wait for a new release of Strawberry


Here's the preview release card for twitter:

Here's the tweet text:

🆕 Release (next) is out! Thanks to Timothy Pansino for the PR 👏

Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)

@Kludex
Copy link
Member

Kludex commented May 15, 2022

Yep. If you're sure it works with Starlette <0.19.0, then it's fine 👍

@AntonOfTheWoods
Copy link
Contributor

Yay! :-)

@Kludex
Copy link
Member

Kludex commented May 19, 2022

Is it an option to have one entry with latest Starlette without FastAPI installed, and skip the tests on FastAPI if not installed?

@patrick91
Copy link
Member

Is it an option to have one entry with latest Starlette without FastAPI installed, and skip the tests on FastAPI if not installed?

one entry of tests?

I tried that in this commit, but it didn't work: 8d553f7

I'm not sure if there's a way to force poetry to install a package, maybe I can try with pip directly, let me see.

@patrick91
Copy link
Member

Is it an option to have one entry with latest Starlette without FastAPI installed, and skip the tests on FastAPI if not installed?

I'm not sure if there's a way to force poetry to install a package, maybe I can try with pip directly, let me see.

well, that sees to have worked! thanks @Kludex

RELEASE.md Outdated Show resolved Hide resolved
@patrick91 patrick91 changed the title Fix compatibility with starlette 0.18.0 Fix compatibility with starlette 0.18.0 and above May 19, 2022
@patrick91 patrick91 merged commit 96f1cfc into strawberry-graphql:main May 19, 2022
@botberry
Copy link
Member

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
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Incompatible with latest version of Starlette (v0.18.0)
8 participants