diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 68f1c40..48a9b2c 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -6,26 +6,45 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
- fail-fast: false
+ fail-fast: true
matrix:
- python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
+ python: ["3.9", "3.10", "3.11", "3.12"]
+ poetry-version: [1.8.2]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- - name: Set up Python
+ - name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- - name: Install Dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -r requirements.txt
+ - name: Set up Poetry ${{ matrix.poetry-version }}
+ uses: abatilo/actions-poetry@v2.0.0
+ with:
+ poetry-version: ${{ matrix.poetry-version }}
+
+ - name: Set up cache
+ uses: actions/cache@v4.0.2
+ id: cache
+ with:
+ path: .venv
+ key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
+
+ - name: Ensure cache is healthy
+ if: steps.cache.outputs.cache-hit == 'true'
+ run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
+
+ - name: Install dependencies
+ if: steps.cache.outputs.cache-hit != 'true'
+ run: poetry install
- name: Code Quality
run: |
- pip install black
- black -l 80 --check .
+ poetry run black -l 80 --check .
+
+ - name: Unit tests
+ run: |
+ poetry run pytest --cov .
diff --git a/examples/example_2.py b/examples/example_2.py
index 6ac5e1c..76d182b 100644
--- a/examples/example_2.py
+++ b/examples/example_2.py
@@ -57,9 +57,7 @@ def map_created_in_view():
)
# print(get_address(api, 22.4761596, 88.4149326))
- return render_template(
- "example_2.html", dmap=dmap, gmap=gmap, wmap=wmap, key=api
- )
+ return render_template("example_2.html", dmap=dmap, gmap=gmap, wmap=wmap, key=api)
if __name__ == "__main__":
diff --git a/examples/simple.py b/examples/simple.py
index f856248..b8a7563 100644
--- a/examples/simple.py
+++ b/examples/simple.py
@@ -12,9 +12,7 @@
"glyph": "",
"scale": 2.0,
}
-image_content = {
- "icon_urls": "https://img.shields.io/badge/PayPal-Donante-red.svg"
-}
+image_content = {"icon_urls": "https://img.shields.io/badge/PayPal-Donante-red.svg"}
@app.route("/")
diff --git a/flask_googlemaps/__init__.py b/flask_googlemaps/__init__.py
index dc2c486..5fc0125 100644
--- a/flask_googlemaps/__init__.py
+++ b/flask_googlemaps/__init__.py
@@ -223,9 +223,7 @@ def build_rectangle_dict(
return rectangle
- def add_rectangle(
- self, north=None, west=None, south=None, east=None, **kwargs
- ):
+ def add_rectangle(self, north=None, west=None, south=None, east=None, **kwargs):
# type: (Optional[float], Optional[float], Optional[float], Optional[float], **Any) -> None
"""Adds a rectangle dict to the Map.rectangles attribute
@@ -261,9 +259,7 @@ def add_rectangle(
if east:
kwargs["bounds"]["east"] = east
- if set(("north", "east", "south", "west")) != set(
- kwargs["bounds"].keys()
- ):
+ if set(("north", "east", "south", "west")) != set(kwargs["bounds"].keys()):
raise AttributeError("rectangle bounds required to rectangles")
kwargs.setdefault("stroke_color", "#FF0000")
@@ -312,9 +308,7 @@ def build_circles(self, circles):
elif isinstance(circle, (tuple, list)):
if len(circle) != 3:
raise AttributeError("circle requires center and radius")
- circle_dict = self.build_circle_dict(
- circle[0], circle[1], circle[2]
- )
+ circle_dict = self.build_circle_dict(circle[0], circle[1], circle[2])
self.add_circle(**circle_dict)
def build_circle_dict(
@@ -363,9 +357,7 @@ def build_circle_dict(
return circle
- def add_circle(
- self, center_lat=None, center_lng=None, radius=None, **kwargs
- ):
+ def add_circle(self, center_lat=None, center_lng=None, radius=None, **kwargs):
# type: (Optional[float], Optional[float], Optional[float], **Any) -> None
"""Adds a circle dict to the Map.circles attribute
@@ -733,9 +725,7 @@ def add_heatmap(self, lat=None, lng=None, **kwargs):
if "lat" not in kwargs or "lng" not in kwargs:
raise AttributeError("heatmap_data requires 'lat' and 'lng' values")
if len(kwargs) > 2:
- raise AttributeError(
- "heatmap_data can only contain 'lat' and 'lng' values"
- )
+ raise AttributeError("heatmap_data can only contain 'lat' and 'lng' values")
self.heatmap_data.append(kwargs)
@@ -779,9 +769,7 @@ def as_json(self):
@property
def js(self):
# type: () -> Markup
- return Markup(
- self.render("googlemaps/gmapjs.html", gmap=self, DEFAULT_PIN="")
- )
+ return Markup(self.render("googlemaps/gmapjs.html", gmap=self, DEFAULT_PIN=""))
@property
def html(self):
@@ -826,24 +814,12 @@ def get_address(API_KEY, lat, lon):
+ "&key="
+ API_KEY
).json()
- add_dict["zip"] = response["results"][0]["address_components"][-1][
- "long_name"
- ]
- add_dict["country"] = response["results"][0]["address_components"][-2][
- "long_name"
- ]
- add_dict["state"] = response["results"][0]["address_components"][-3][
- "long_name"
- ]
- add_dict["city"] = response["results"][0]["address_components"][-4][
- "long_name"
- ]
- add_dict["locality"] = response["results"][0]["address_components"][-5][
- "long_name"
- ]
- add_dict["road"] = response["results"][0]["address_components"][-6][
- "long_name"
- ]
+ add_dict["zip"] = response["results"][0]["address_components"][-1]["long_name"]
+ add_dict["country"] = response["results"][0]["address_components"][-2]["long_name"]
+ add_dict["state"] = response["results"][0]["address_components"][-3]["long_name"]
+ add_dict["city"] = response["results"][0]["address_components"][-4]["long_name"]
+ add_dict["locality"] = response["results"][0]["address_components"][-5]["long_name"]
+ add_dict["road"] = response["results"][0]["address_components"][-6]["long_name"]
add_dict["formatted_address"] = response["results"][0]["formatted_address"]
return add_dict
@@ -881,9 +857,7 @@ def init_app(self, app):
app.add_template_global(googlemap_obj)
app.add_template_filter(googlemap)
app.add_template_global(googlemap)
- app.add_template_global(
- app.config.get("GOOGLEMAPS_KEY"), name="GOOGLEMAPS_KEY"
- )
+ app.add_template_global(app.config.get("GOOGLEMAPS_KEY"), name="GOOGLEMAPS_KEY")
app.add_template_global(set_googlemaps_loaded)
app.add_template_global(is_googlemaps_loaded)
diff --git a/pyproject.toml b/pyproject.toml
index 449aee8..1a81166 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -45,5 +45,5 @@ pytest-cov = "^5.0.0"
mypy = "^1.9.0"
[build-system]
-requires = ["poetry>=1.1.2"]
+requires = ["poetry>=1.8.2"]
build-backend = "poetry.masonry.api"
diff --git a/tests/test_map.py b/tests/test_map.py
index 3f7409b..7eed1a2 100644
--- a/tests/test_map.py
+++ b/tests/test_map.py
@@ -7,18 +7,16 @@
@pytest.fixture
def map_properties() -> Dict[str, Any]:
- return dict(identifier="gmap",
- varname="gmap",
- lat=37.4419,
- lng=-122.1419)
+ return dict(identifier="gmap", varname="gmap", lat=37.4419, lng=-122.1419)
@pytest.fixture
def markers() -> List[Dict]:
return [
{
- "content": {"icon_url": "http://maps.google.com/"
- "mapfiles/ms/icons/green-dot.png"},
+ "content": {
+ "icon_url": "http://maps.google.com/" "mapfiles/ms/icons/green-dot.png"
+ },
"latitude": 37.4419,
"longitude": -122.1419,
"infobox": "Hello World",
@@ -33,7 +31,7 @@ def markers() -> List[Dict]:
"background": "",
"glyph": "",
"scale": 2.0,
- }
+ },
},
]
diff --git a/tests/test_marker.py b/tests/test_marker.py
index 79144ed..100471c 100644
--- a/tests/test_marker.py
+++ b/tests/test_marker.py
@@ -21,8 +21,8 @@ def marker_pin_url() -> Marker:
longitude=-122.1419,
content={
"icon_url": "https://developers.google.com/maps/"
- "documentation/javascript/examples/"
- "full/images/beachflag.png"
+ "documentation/javascript/examples/"
+ "full/images/beachflag.png"
},
infobox="Hello World",
)