Skip to content

Remove deprecated werkzeug import #35

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

Merged
merged 4 commits into from
Feb 19, 2020
Merged

Remove deprecated werkzeug import #35

merged 4 commits into from
Feb 19, 2020

Conversation

plowman
Copy link
Contributor

@plowman plowman commented Feb 7, 2020

Fixes: #34

This import breaks with werkzeug 1.0.

Before 1.0, werkzeug was generating this warning:

DeprecationWarning: The import 'werkzeug.cached_property' is deprecated and will be removed in Werkzeug 1.0. Use 'from werkzeug.utils import cached_property' instead.

@ziirish
Copy link
Contributor

ziirish commented Feb 7, 2020

Thanks for your contribution.

Werkzeug dropped the support of python3.4 pallets/werkzeug#1478 that is the reason why your tests are failing.

@SteadBytes, @j5awry I think we should drop support for python 3.4 as well, we'll then end up with a v0.2.0 I guess.
Any thoughts?

@sloria
Copy link

sloria commented Feb 7, 2020

+1 to dropping Python 3.4. It's over 6 years old at this point, and Python 3.9 is around the corner.

@j5awry
Copy link
Contributor

j5awry commented Feb 7, 2020

+1 for killing 3.4, and accepting this PR as is. Opening a ticket for Werkzeug and Flask pinning / uprevving and removing python 3.4 from our allowables

@@ -413,7 +413,7 @@ def test_handle_non_api_error(self, app, client):

response = client.get("/foo")
assert response.status_code == 404
assert response.headers['Content-Type'] == 'text/html'
assert response.headers['Content-Type'] == 'text/html; charset=utf-8'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the addition of charset here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced by werkzeug 1.0 as well.
Related to pallets/werkzeug#1526

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain this in the commit message @plowman 😄

Copy link
Contributor Author

@plowman plowman Feb 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, I disagree about how useful this information will be for future commit archaeologists but sure, commit message: updated.

@@ -413,7 +413,7 @@ def test_handle_non_api_error(self, app, client):

response = client.get("/foo")
assert response.status_code == 404
assert response.headers['Content-Type'] == 'text/html'
assert response.headers['Content-Type'] == 'text/html; charset=utf-8'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks the tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's more complicated than that.

Only one test remains broken: the one running python 3.4
At first, we may think this change breaks the test, but in fact, what is really broken is the fact that werkzeug 1.0 is NOT available for python 3.4 hence the tests are running with an old version of werkzeug which does not insert the charset in the Content-Type header.

The proper fix is to remove python 3.4 from the test suite and completely drop support for python 3.4 (which is EOL for almost a year).

@plowman
Copy link
Contributor Author

plowman commented Feb 7, 2020

Hey @ziirish thanks for taking a look! Let me know if there's anything else you'd like to see in this PR.

Also, I rebased from master and the tests are now failing for different reasons:

Not on TravisCI. You have to provide either repo_token in .coveralls.yml or set the COVERALLS_REPO_TOKEN env var.

So it seems like it's expecting secrets.COVERALLS_REPO_TOKEN to be defined in github? But I'm not familiar with coveralls so that could be incorrect.

This breaks with werkzeug 1.0. Werkzeug was previously generating this warning: DeprecationWarning: The import 'werkzeug.cached_property' is deprecated and will be removed in Werkzeug 1.0. Use 'from werkzeug.utils import cached_property' instead.
This package also has a bug related to importing werkzeug 1.0 which they fixed in 0.15.1.
As of werkzeug 1.0 the content-type changed to include "charset=utf-8".
The tests right now are broken on earlier werkzeug versions. Allow the latest werkzeug version so the tests pass.
Copy link
Contributor

@ziirish ziirish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ziirish ziirish merged commit 312a540 into python-restx:master Feb 19, 2020
@ntungare
Copy link

ntungare commented Mar 6, 2020

Still facing this issue, would love a version upgrade since the fix is in already.

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.

Werkzeug V1.x breaks restx import
10 participants