Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update ci pipeline and poetry version #160

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ jobs:
cache-dependency-path: poetry.lock

- name: Install dependencies
run: poetry install
run: make install

- name: Code Quality
run: |
poetry run black -l 80 --check .
run: make quality

- name: Unit tests
run: |
poetry run pytest --cov .
run: make test
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
.PHONY: test pep8 types clean install build publish tree env
.PHONY: test quality pep8 black types clean install build publish tree env

test: pep8
py.test --cov=flask_googlemaps -l --tb=short --maxfail=1 tests/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was necessary to remove the -l --tb=short --maxfail=1 tests/ flags?

test:
@poetry run pytest --cov .

quality: pep8 black

pep8:
@flake8 flask_googlemaps --ignore=F403
@poetry run flake8 flask_googlemaps --ignore=F403

black:
@poetry run black -l 80 --check .

types:
@mypy --py2 flask_googlemaps
Expand Down
18 changes: 11 additions & 7 deletions flask_googlemaps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
__version__ = "0.4.1"

from json import dumps
from typing import Optional, Dict, Any, List, Union, Tuple, Text
from typing import Optional, Dict, Any, List, Union, Tuple, Text # noqa: F401

import requests
from flask import Blueprint, Markup, g, render_template

from flask_googlemaps.icons import dots, Icon
from flask_googlemaps.icons import dots, Icon # noqa: F401

DEFAULT_ICON = dots.red
DEFAULT_CLUSTER_IMAGE_PATH = "static/images/m"
Expand All @@ -27,7 +28,8 @@ def __init__(
cls="map", # type: str
language="en", # type: str
region="US", # type: str
rectangles=None, # type: Optional[List[Union[List, Tuple, Tuple[Tuple], Dict]]]
rectangles=None,
# type: Optional[List[Union[List, Tuple, Tuple[Tuple], Dict]]]
circles=None, # type: Optional[List[Union[List, Tuple, Dict]]]
polylines=None, # type: Optional[List[Union[List, Tuple, Dict]]]
polygons=None, # type: Optional[List[Union[List, Tuple, Dict]]]
Expand Down Expand Up @@ -269,7 +271,7 @@ def build_rectangle_dict(
def add_rectangle(
self, north=None, west=None, south=None, east=None, **kwargs
):
# type: (Optional[float], Optional[float], Optional[float], Optional[float], **Any) -> None
# type: (Optional[float], Optional[float], Optional[float], Optional[float], **Any) -> None # noqa: E501
"""Adds a rectangle dict to the Map.rectangles attribute

The Google Maps API describes a rectangle using the LatLngBounds
Expand Down Expand Up @@ -757,14 +759,16 @@ def build_heatmap(self, heatmap_data, heatmap_layer):
raise AttributeError("heatmap_later requires 'heatmap_data'")
if not isinstance(heatmap_data, (list)):
raise AttributeError(
"heatmap_data only accepts a list of dicts with keys 'lat' 'lng' and their corresponding values"
"heatmap_data only accepts a list of dicts with keys "
"'lat' 'lng' and their corresponding values"
)
for hm in heatmap_data:
if isinstance(hm, dict):
self.add_heatmap(**hm)
else:
raise AttributeError(
"elements of list 'heatmap_data' must be a dict of keys 'lat' and 'lng' with their corresponding values"
"elements of list 'heatmap_data' must be a dict of keys "
"'lat' and 'lng' with their corresponding values"
)

def add_heatmap(self, lat=None, lng=None, **kwargs):
Expand Down Expand Up @@ -877,7 +881,7 @@ def set_googlemaps_loaded():
def get_address(API_KEY, lat, lon):
# type: (str, float, float) -> dict
add_dict = dict()
response = rq.get(
response = requests.get(
"https://maps.googleapis.com/maps/api/geocode/json?latlng="
+ ",".join(map(str, [lat, lon]))
+ "&key="
Expand Down
2 changes: 1 addition & 1 deletion flask_googlemaps/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

__all__ = ["dots", "alpha", "shapes", "pushpin", "paddle"]

from typing import Optional, List
from typing import Optional, List # noqa: F401


class Icon(object):
Expand Down