flask-extensions / Flask-GoogleMaps

Easy way to add GoogleMaps to Flask applications. maintainer: @getcake
https://flask-googlemaps.com
MIT License
647 stars 196 forks source link

[bug] import "Markup" fails when using Flask 3.0+ in __init__.py #157

Open LeoNatanian opened 8 months ago

LeoNatanian commented 8 months ago

Describe the bug ImportError: cannot import name 'Markup' from 'flask' (/home/lnatanian/dev/project/venv/lib/python3.12/site-packages/flask/__init__.py)

Since Flask is using Jinja2 for quite some time, they removed the re-export of Markup with the 3.0.0 release, see GitHub.

To Reproduce Steps to reproduce the behavior:

  1. Install Flask 3.0 or better
  2. Install Flask-GoogleMaps
  3. Attempt to import googlemaps in your init.

Expected behavior GoogleMaps should work with Flask version 3.0+

Workaround I modified __init__.py in the Flask-GoogleMaps app and imported from another pip package called markupsafe. This may have introduced a new dependency though.

from json import dumps
import requests as rq

import requests
# MODIFIED-Importing Markup from another Package
from markupsafe import Markup
from flask import Blueprint, g, render_template

from flask_googlemaps.icons import dots

Traceback

Traceback (most recent call last):
  File "/home/lnatanian/dev/project/main.py", line 1, in <module>
    from app import app
  File "/home/lnatanian/dev/project/app/__init__.py", line 7, in <module>
    from flask_googlemaps import GoogleMaps
  File "/home/lnatanian/dev/project/venv/lib/python3.12/site-packages/flask_googlemaps/__init__.py", line 9, in <module>
    from flask import Blueprint, Markup, g, render_template
ImportError: cannot import name 'Markup' from 'flask' (/home/lnatanian/dev/project/venv/lib/python3.12/site-packages/flask/__init__.py)