Skip to content

Commit

Permalink
Update poetry version and ci.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
argysamo committed Apr 17, 2024
1 parent 9af693c commit 6e602f4
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 64 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Set up cache
uses: actions/[email protected]
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 .
4 changes: 1 addition & 3 deletions examples/example_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
4 changes: 1 addition & 3 deletions examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("/")
Expand Down
52 changes: 13 additions & 39 deletions flask_googlemaps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 5 additions & 7 deletions tests/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<b>Hello World</b>",
Expand All @@ -33,7 +31,7 @@ def markers() -> List[Dict]:
"background": "",
"glyph": "",
"scale": 2.0,
}
},
},
]

Expand Down
4 changes: 2 additions & 2 deletions tests/test_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="<b>Hello World</b>",
)
Expand Down

0 comments on commit 6e602f4

Please sign in to comment.