Skip to content

Commit 44cafa0

Browse files
authored
fix: fixed code quality issues (#398)
* Add .deepsource.toml * Fixed Object Inheritance * Replace ternary syntax with if expression * Use literal syntax to create data structure
1 parent 5253cbc commit 44cafa0

6 files changed

Lines changed: 26 additions & 34 deletions

File tree

.deepsource.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version = 1
2+
3+
test_patterns = ["tests/**"]
4+
5+
[[analyzers]]
6+
name = "python"
7+
enabled = true
8+
9+
[analyzers.meta]
10+
runtime_version = "3.x.x"

googlemaps/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
_USER_AGENT = "GoogleGeoApiClientPython/%s" % googlemaps.__version__
4444
_DEFAULT_BASE_URL = "https://maps.googleapis.com"
4545

46-
_RETRIABLE_STATUSES = set([500, 503, 504])
46+
_RETRIABLE_STATUSES = {500, 503, 504}
4747

4848

49-
class Client(object):
49+
class Client:
5050
"""Performs requests to the Google Maps API web services."""
5151

5252
def __init__(self, key=None, client_id=None, client_secret=None,

googlemaps/convert.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ def _is_list(arg):
160160
return False
161161
if isinstance(arg, str): # Python 3-only, as str has __iter__
162162
return False
163-
return (not _has_method(arg, "strip")
164-
and _has_method(arg, "__getitem__")
165-
or _has_method(arg, "__iter__"))
163+
return _has_method(arg, "__getitem__") if not _has_method(arg, "strip") else _has_method(arg, "__iter__")
166164

167165

168166
def is_string(val):

googlemaps/maps.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,11 @@
2020
from googlemaps import convert
2121

2222

23-
MAPS_IMAGE_FORMATS = set(
24-
['png8', 'png', 'png32', 'gif', 'jpg', 'jpg-baseline']
25-
)
23+
MAPS_IMAGE_FORMATS = {'png8', 'png', 'png32', 'gif', 'jpg', 'jpg-baseline'}
2624

27-
MAPS_MAP_TYPES = set(
28-
['roadmap', 'satellite', 'terrain', 'hybrid']
29-
)
25+
MAPS_MAP_TYPES = {'roadmap', 'satellite', 'terrain', 'hybrid'}
3026

31-
32-
class StaticMapParam(object):
27+
class StaticMapParam:
3328
"""Base class to handle parameters for Maps Static API."""
3429

3530
def __init__(self):

googlemaps/places.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
from googlemaps import convert
2222

2323

24-
PLACES_FIND_FIELDS_BASIC = set(
25-
[
26-
"business_status",
24+
PLACES_FIND_FIELDS_BASIC = {"business_status",
2725
"formatted_address",
2826
"geometry",
2927
"geometry/location",
@@ -42,23 +40,19 @@
4240
"photos",
4341
"place_id",
4442
"plus_code",
45-
"types",
46-
]
47-
)
43+
"types",}
4844

49-
PLACES_FIND_FIELDS_CONTACT = set(["opening_hours"])
45+
PLACES_FIND_FIELDS_CONTACT = {"opening_hours"}
5046

51-
PLACES_FIND_FIELDS_ATMOSPHERE = set(["price_level", "rating", "user_ratings_total"])
47+
PLACES_FIND_FIELDS_ATMOSPHERE = {"price_level", "rating", "user_ratings_total"}
5248

5349
PLACES_FIND_FIELDS = (
5450
PLACES_FIND_FIELDS_BASIC
5551
^ PLACES_FIND_FIELDS_CONTACT
5652
^ PLACES_FIND_FIELDS_ATMOSPHERE
5753
)
5854

59-
PLACES_DETAIL_FIELDS_BASIC = set(
60-
[
61-
"address_component",
55+
PLACES_DETAIL_FIELDS_BASIC = {"address_component",
6256
"adr_address",
6357
"business_status",
6458
"formatted_address",
@@ -82,17 +76,11 @@
8276
"type",
8377
"url",
8478
"utc_offset",
85-
"vicinity",
86-
]
87-
)
79+
"vicinity",}
8880

89-
PLACES_DETAIL_FIELDS_CONTACT = set(
90-
["formatted_phone_number", "international_phone_number", "opening_hours", "website"]
91-
)
81+
PLACES_DETAIL_FIELDS_CONTACT = {"formatted_phone_number", "international_phone_number", "opening_hours", "website"}
9282

93-
PLACES_DETAIL_FIELDS_ATMOSPHERE = set(
94-
["price_level", "rating", "review", "user_ratings_total"]
95-
)
83+
PLACES_DETAIL_FIELDS_ATMOSPHERE = {"price_level", "rating", "review", "user_ratings_total"}
9684

9785
PLACES_DETAIL_FIELDS = (
9886
PLACES_DETAIL_FIELDS_BASIC
@@ -658,3 +646,4 @@ def _autocomplete(
658646

659647
url = "/maps/api/place/%sautocomplete/json" % url_part
660648
return client._request(url, params).get("predictions", [])
649+

tests/test_timezone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_los_angeles(self):
5353
responses.calls[0].request.url,
5454
)
5555

56-
class MockDatetime(object):
56+
class MockDatetime:
5757
def now(self):
5858
return datetime.datetime.fromtimestamp(1608)
5959

0 commit comments

Comments
 (0)