Skip to content

Commit 6e602f4

Browse files
committed
Update poetry version and ci.yaml
1 parent 9af693c commit 6e602f4

File tree

7 files changed

+51
-64
lines changed

7 files changed

+51
-64
lines changed

.github/workflows/ci.yaml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,45 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88
strategy:
9-
fail-fast: false
9+
fail-fast: true
1010
matrix:
11-
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
11+
python: ["3.9", "3.10", "3.11", "3.12"]
12+
poetry-version: [1.8.2]
1213

1314
steps:
1415
- uses: actions/checkout@v4
1516
with:
1617
fetch-depth: 1
1718

18-
- name: Set up Python
19+
- name: Set up Python ${{ matrix.python }}
1920
uses: actions/setup-python@v5
2021
with:
2122
python-version: ${{ matrix.python }}
2223

23-
- name: Install Dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install -r requirements.txt
24+
- name: Set up Poetry ${{ matrix.poetry-version }}
25+
uses: abatilo/[email protected]
26+
with:
27+
poetry-version: ${{ matrix.poetry-version }}
28+
29+
- name: Set up cache
30+
uses: actions/[email protected]
31+
id: cache
32+
with:
33+
path: .venv
34+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
35+
36+
- name: Ensure cache is healthy
37+
if: steps.cache.outputs.cache-hit == 'true'
38+
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
39+
40+
- name: Install dependencies
41+
if: steps.cache.outputs.cache-hit != 'true'
42+
run: poetry install
2743

2844
- name: Code Quality
2945
run: |
30-
pip install black
31-
black -l 80 --check .
46+
poetry run black -l 80 --check .
47+
48+
- name: Unit tests
49+
run: |
50+
poetry run pytest --cov .

examples/example_2.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ def map_created_in_view():
5757
)
5858

5959
# print(get_address(api, 22.4761596, 88.4149326))
60-
return render_template(
61-
"example_2.html", dmap=dmap, gmap=gmap, wmap=wmap, key=api
62-
)
60+
return render_template("example_2.html", dmap=dmap, gmap=gmap, wmap=wmap, key=api)
6361

6462

6563
if __name__ == "__main__":

examples/simple.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
"glyph": "",
1313
"scale": 2.0,
1414
}
15-
image_content = {
16-
"icon_urls": "https://img.shields.io/badge/PayPal-Donante-red.svg"
17-
}
15+
image_content = {"icon_urls": "https://img.shields.io/badge/PayPal-Donante-red.svg"}
1816

1917

2018
@app.route("/")

flask_googlemaps/__init__.py

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,7 @@ def build_rectangle_dict(
223223

224224
return rectangle
225225

226-
def add_rectangle(
227-
self, north=None, west=None, south=None, east=None, **kwargs
228-
):
226+
def add_rectangle(self, north=None, west=None, south=None, east=None, **kwargs):
229227
# type: (Optional[float], Optional[float], Optional[float], Optional[float], **Any) -> None
230228
"""Adds a rectangle dict to the Map.rectangles attribute
231229
@@ -261,9 +259,7 @@ def add_rectangle(
261259
if east:
262260
kwargs["bounds"]["east"] = east
263261

264-
if set(("north", "east", "south", "west")) != set(
265-
kwargs["bounds"].keys()
266-
):
262+
if set(("north", "east", "south", "west")) != set(kwargs["bounds"].keys()):
267263
raise AttributeError("rectangle bounds required to rectangles")
268264

269265
kwargs.setdefault("stroke_color", "#FF0000")
@@ -312,9 +308,7 @@ def build_circles(self, circles):
312308
elif isinstance(circle, (tuple, list)):
313309
if len(circle) != 3:
314310
raise AttributeError("circle requires center and radius")
315-
circle_dict = self.build_circle_dict(
316-
circle[0], circle[1], circle[2]
317-
)
311+
circle_dict = self.build_circle_dict(circle[0], circle[1], circle[2])
318312
self.add_circle(**circle_dict)
319313

320314
def build_circle_dict(
@@ -363,9 +357,7 @@ def build_circle_dict(
363357

364358
return circle
365359

366-
def add_circle(
367-
self, center_lat=None, center_lng=None, radius=None, **kwargs
368-
):
360+
def add_circle(self, center_lat=None, center_lng=None, radius=None, **kwargs):
369361
# type: (Optional[float], Optional[float], Optional[float], **Any) -> None
370362
"""Adds a circle dict to the Map.circles attribute
371363
@@ -733,9 +725,7 @@ def add_heatmap(self, lat=None, lng=None, **kwargs):
733725
if "lat" not in kwargs or "lng" not in kwargs:
734726
raise AttributeError("heatmap_data requires 'lat' and 'lng' values")
735727
if len(kwargs) > 2:
736-
raise AttributeError(
737-
"heatmap_data can only contain 'lat' and 'lng' values"
738-
)
728+
raise AttributeError("heatmap_data can only contain 'lat' and 'lng' values")
739729

740730
self.heatmap_data.append(kwargs)
741731

@@ -779,9 +769,7 @@ def as_json(self):
779769
@property
780770
def js(self):
781771
# type: () -> Markup
782-
return Markup(
783-
self.render("googlemaps/gmapjs.html", gmap=self, DEFAULT_PIN="")
784-
)
772+
return Markup(self.render("googlemaps/gmapjs.html", gmap=self, DEFAULT_PIN=""))
785773

786774
@property
787775
def html(self):
@@ -826,24 +814,12 @@ def get_address(API_KEY, lat, lon):
826814
+ "&key="
827815
+ API_KEY
828816
).json()
829-
add_dict["zip"] = response["results"][0]["address_components"][-1][
830-
"long_name"
831-
]
832-
add_dict["country"] = response["results"][0]["address_components"][-2][
833-
"long_name"
834-
]
835-
add_dict["state"] = response["results"][0]["address_components"][-3][
836-
"long_name"
837-
]
838-
add_dict["city"] = response["results"][0]["address_components"][-4][
839-
"long_name"
840-
]
841-
add_dict["locality"] = response["results"][0]["address_components"][-5][
842-
"long_name"
843-
]
844-
add_dict["road"] = response["results"][0]["address_components"][-6][
845-
"long_name"
846-
]
817+
add_dict["zip"] = response["results"][0]["address_components"][-1]["long_name"]
818+
add_dict["country"] = response["results"][0]["address_components"][-2]["long_name"]
819+
add_dict["state"] = response["results"][0]["address_components"][-3]["long_name"]
820+
add_dict["city"] = response["results"][0]["address_components"][-4]["long_name"]
821+
add_dict["locality"] = response["results"][0]["address_components"][-5]["long_name"]
822+
add_dict["road"] = response["results"][0]["address_components"][-6]["long_name"]
847823
add_dict["formatted_address"] = response["results"][0]["formatted_address"]
848824
return add_dict
849825

@@ -881,9 +857,7 @@ def init_app(self, app):
881857
app.add_template_global(googlemap_obj)
882858
app.add_template_filter(googlemap)
883859
app.add_template_global(googlemap)
884-
app.add_template_global(
885-
app.config.get("GOOGLEMAPS_KEY"), name="GOOGLEMAPS_KEY"
886-
)
860+
app.add_template_global(app.config.get("GOOGLEMAPS_KEY"), name="GOOGLEMAPS_KEY")
887861
app.add_template_global(set_googlemaps_loaded)
888862
app.add_template_global(is_googlemaps_loaded)
889863

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ pytest-cov = "^5.0.0"
4545
mypy = "^1.9.0"
4646

4747
[build-system]
48-
requires = ["poetry>=1.1.2"]
48+
requires = ["poetry>=1.8.2"]
4949
build-backend = "poetry.masonry.api"

tests/test_map.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@
77

88
@pytest.fixture
99
def map_properties() -> Dict[str, Any]:
10-
return dict(identifier="gmap",
11-
varname="gmap",
12-
lat=37.4419,
13-
lng=-122.1419)
10+
return dict(identifier="gmap", varname="gmap", lat=37.4419, lng=-122.1419)
1411

1512

1613
@pytest.fixture
1714
def markers() -> List[Dict]:
1815
return [
1916
{
20-
"content": {"icon_url": "http://maps.google.com/"
21-
"mapfiles/ms/icons/green-dot.png"},
17+
"content": {
18+
"icon_url": "http://maps.google.com/" "mapfiles/ms/icons/green-dot.png"
19+
},
2220
"latitude": 37.4419,
2321
"longitude": -122.1419,
2422
"infobox": "<b>Hello World</b>",
@@ -33,7 +31,7 @@ def markers() -> List[Dict]:
3331
"background": "",
3432
"glyph": "",
3533
"scale": 2.0,
36-
}
34+
},
3735
},
3836
]
3937

tests/test_marker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def marker_pin_url() -> Marker:
2121
longitude=-122.1419,
2222
content={
2323
"icon_url": "https://developers.google.com/maps/"
24-
"documentation/javascript/examples/"
25-
"full/images/beachflag.png"
24+
"documentation/javascript/examples/"
25+
"full/images/beachflag.png"
2626
},
2727
infobox="<b>Hello World</b>",
2828
)

0 commit comments

Comments
 (0)