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

[3.3 branch] address deprecation of werkzeug.urls.url_parse #1144

Merged

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented May 4, 2023

This is a fix for #1142 for the 3.3-maintenance branch.

Issue(s) Resolved

Fixes #1142

Related Issues / Links

See #1143 for the corresponding PR for the master branch.

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)

Pin werkzeug<2.4

Our Publisher API currently involves passing a werkzeug.urls.URL instance as the target_url argument to Publisher.publish.

As there are several Lektor plugins in the wild that implement their own custom publishers, and all of them currently expect that target_url will be a werkzeug.urls.URL instance, totally eliminating our use of the deprecated URL class (without breaking existing plugins) is tricky. (See #1143 for a PR that does this in the master branch.)

This PR takes the approach that we will keep the current Publisher API for Lektor 3.3.x. So here we pin werkzeug<2.4 to ensure that werkzeug.urls.URL remains available.

Other bits

This PR does disuse the deprecated bits of werkzeug.urls in the cases where that is fairly straightforward.

This PR also backports e2d0274 in order to allow the user to customize Python's warnings filter, should s/he so desire.

These are leftovers from python 2.x support.  In the one case where
the __str__ and __unicode__ methods differ, rename the __unicode__
method to __str__.
This is a backport of e2d0274.

Currently the Lektor CLI unconditionally sets the warnings filter to
"default". There is no way of the user to configure this.

Here we bypass re-configuring the warnings filter if it has already
been customized, either via the PYTHONWARNINGS environment variable or
by python's -W flag.

E.g., now one can show all warnings by doing either of:

    PYTHONWARNINGS=always lektor build

or

    python -W always -m lektor build

Ref: https://docs.python.org/3/library/warnings.html#overriding-the-default-filter
Our Publisher API involves passing a `werkzeug.urls.URL` instance to
`Publisher.publish`.  As this is an API assumed by custom publishers
implemented by Lektor plugins out in the wild, we can not simply
change the API.

PR lektor#1143 — in the master branch — implements one approach to updating
the API in a backward-compatible manner, but it is rather involved.

For the sake of the 3.3.x branch, for now we pin werkzeug<2.4 and
leave the Publisher API as it is.
@dairiki dairiki force-pushed the fix.3.3-werkzeug.urls.deprecation branch from 4c37f4b to 01cfbd0 Compare May 5, 2023 21:30
@dairiki dairiki merged commit 2231baa into lektor:3.3-maintenance May 5, 2023
15 checks passed
@dairiki dairiki deleted the fix.3.3-werkzeug.urls.deprecation branch May 5, 2023 21:45
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.

None yet

1 participant