web-dev-qa-db-fra.com

Changement de rupture de WTForms 2.3.0 - ImportError: impossible d'importer le nom 'HTMLString' depuis 'wtforms.widgets'

WTForms a été mis à jour en 2.3.0 avec un changement de rupture. J'ai essayé d'ajuster d'autres exigences telles que werkzeug.1.0.0 mais pas encore de chance. Est-ce que quelqu'un a trouvé une solution?

Voici la séquence de pile:

Traceback (most recent call last):
   File "/usr/local/bin/celery", line 8, in <module>
     sys.exit(main())
   File "/usr/local/lib/python3.8/site-packages/celery/__main__.py", line 16, in main
     _main()
   File "/usr/local/lib/python3.8/site-packages/celery/bin/celery.py", line 322, in main
     cmd.execute_from_commandline(argv)
   File "/usr/local/lib/python3.8/site-packages/celery/bin/celery.py", line 495, in execute_from_commandline
     super(CeleryCommand, self).execute_from_commandline(argv)))
   File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 289, in execute_from_commandline
     argv = self.setup_app_from_commandline(argv)
   File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 509, in setup_app_from_commandline
     self.app = self.find_app(app)
   File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 531, in find_app
     return find_app(app, symbol_by_name=self.symbol_by_name)
   File "/usr/local/lib/python3.8/site-packages/celery/app/utils.py", line 373, in find_app
     sym = symbol_by_name(app, imp=imp)
   File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 534, in symbol_by_name
     return imports.symbol_by_name(name, imp=imp)
   File "/usr/local/lib/python3.8/site-packages/kombu/utils/imports.py", line 57, in symbol_by_name
     module = imp(module_name, package=package, **kwargs)
   File "/usr/local/lib/python3.8/site-packages/celery/utils/imports.py", line 111, in import_from_cwd
     return imp(module, package=package)
   File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
   File "<frozen importlib._bootstrap_external>", line 783, in exec_module
   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
   File "/prosebit/prosebit/blueprints/contact/__init__.py", line 1, in <module>
     from prosebit.blueprints.contact.views import contact
   File "/prosebit/prosebit/blueprints/contact/views.py", line 10, in <module>
     from prosebit.blueprints.contact.forms import ContactForm
   File "/prosebit/prosebit/blueprints/contact/forms.py", line 3, in <module>
     from wtforms_components import EmailField
   File "/usr/local/lib/python3.8/site-packages/wtforms_components/__init__.py", line 3, in <module>
     from .fields import (
   File "/usr/local/lib/python3.8/site-packages/wtforms_components/fields/__init__.py", line 2, in <module>
     from .color import ColorField
   File "/usr/local/lib/python3.8/site-packages/wtforms_components/fields/color.py", line 1, in <module>
     from ..widgets import ColorInput
   File "/usr/local/lib/python3.8/site-packages/wtforms_components/widgets.py", line 5, in <module>
     from wtforms.widgets import html_params, HTMLString, Input
 ImportError: cannot import name 'HTMLString' from 'wtforms.widgets' (/usr/local/lib/python3.8/site-packages/wtforms/widg
ets/__init__.py)

Et voici mes exigences:

Flask==1.1.1
werkzeug==0.16.0

# Application server for both development and production.
gunicorn==20.0.4

# Testing and static analysis.
pytest==5.3.2
pytest-cov==2.8.1
mock==3.0.5
flake8==3.7.9

# CLI.
# Click==6.4

# Data and workers.
# psycopg2==2.6.1
psycopg2==2.8.4
Flask-SQLAlchemy==2.4.1
SQLAlchemy==1.3.12

redis==3.3.11
celery==4.4.0

# Forms.
Flask-WTF==0.14.3
WTForms-Components==0.10.4
WTForms-Alchemy==0.16.9

# Utils.
# fake-factory==0.5.7
faker==3.0.0

# Extensions.
flask-debugtoolbar==0.11.0
Flask-Mail==0.9.1
Flask-Login==0.4.1

# Payments.
stripe==2.41.0
gocardless_pro==1.10.0

# Google API requirements
google-api-core==1.16.0
google-cloud-pubsub==1.4.3 # Not compatible with google-api-core: 1.17.0
google-api-python-client==1.8.0
httplib2==0.17.2
oauth2client==4.1.3
google-auth==1.14.0 # Used for google.oauth2.credentials
google-auth-oauthlib==0.4.1
3
polymath

En plus de la réponse de JBLaf, HTMLString a été remplacé par Markup. Alors utilisez from markupsafe import Markup au lieu.

from wtforms.widgets.core import escape_html a également été remplacé par from markupsafe import escape

Dans WTForms 2.3.1 ces termes sont rajoutés en tant qu'alias et un avertissement d'obsolescence est affiché au lieu d'un changement de rupture.

0
polymath