flask-extensions / flask-extensions/Flask-GoogleMaps

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

Open
#157 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
655
Forks
193
PR merge metrics
No merged PRs in 30d

Description

**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](https://github.com/pallets/flask/pull/5223).

**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
from app import app
File "/home/lnatanian/dev/project/app/__init__.py", line 7, in
from flask_googlemaps import GoogleMaps
File "/home/lnatanian/dev/project/venv/lib/python3.12/site-packages/flask_googlemaps/__init__.py", line 9, in
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)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.