Skip to content

Commit bcea17e

Browse files
committed
[CI] Add pre-commit hook pyupgrade to auto upgrade Python syntax
"A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language." https://github.com/asottile/pyupgrade
1 parent c6d7969 commit bcea17e

8 files changed

+31
-39
lines changed

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ repos:
1010
hooks:
1111
- id: identity
1212
- id: check-hooks-apply
13+
- repo: https://github.com/asottile/pyupgrade
14+
rev: v3.18.0
15+
hooks:
16+
- id: pyupgrade
1317
- repo: https://github.com/psf/black-pre-commit-mirror
1418
rev: 24.10.0
1519
hooks:

python/sedona/core/jvm/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from sedona.utils.decorators import classproperty
3030

31-
string_types = (type(b""), type(""))
31+
string_types = (bytes, str)
3232

3333

3434
def is_greater_or_equal_version(version_a: str, version_b: str) -> bool:

python/sedona/maps/SedonaPyDeck.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def _create_default_fill_color_(cls, gdf, plot_col):
315315
:return: fill_color string for pydeck map
316316
"""
317317
plot_max = gdf[plot_col].max()
318-
return "[85, 183, 177, ({0} / {1}) * 255 + 15]".format(plot_col, plot_max)
318+
return "[85, 183, 177, ({} / {}) * 255 + 15]".format(plot_col, plot_max)
319319

320320
@classmethod
321321
def _create_coord_column_(cls, gdf, geometry_col, add_points=False):

python/sedona/utils/decorators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
T = TypeVar("T")
2121

2222

23-
class classproperty(object):
23+
class classproperty:
2424

2525
def __init__(self, f):
2626
self.f = f

python/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from sedona import version
2323

24-
with open("README.md", "r") as fh:
24+
with open("README.md") as fh:
2525
long_description = fh.read()
2626

2727
extension_args = {}

python/tests/core/test_avoiding_python_jvm_serde_df.py

+14-18
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,20 @@ def test_spatial_join_query_flat_to_df(self):
165165
right_geometries = self.__row_to_list(right_geometries_raw)
166166

167167
# Ignore the ordering of these
168-
assert set(geom[0] for geom in left_geometries) == set(
169-
[
170-
"POLYGON ((0 4, -3 3, -8 6, -6 8, -2 9, 0 4))",
171-
"POLYGON ((10 3, 10 6, 14 6, 14 3, 10 3))",
172-
"POLYGON ((2 2, 2 4, 3 5, 7 5, 9 3, 8 1, 4 1, 2 2))",
173-
"POLYGON ((-1 -1, -1 -3, -2 -5, -6 -8, -5 -2, -3 -2, -1 -1))",
174-
"POLYGON ((-1 -1, -1 -3, -2 -5, -6 -8, -5 -2, -3 -2, -1 -1))",
175-
]
176-
)
177-
assert set(geom[0] for geom in right_geometries) == set(
178-
[
179-
"POINT (-3 5)",
180-
"POINT (11 5)",
181-
"POINT (4 3)",
182-
"POINT (-1 -1)",
183-
"POINT (-4 -5)",
184-
]
185-
)
168+
assert {geom[0] for geom in left_geometries} == {
169+
"POLYGON ((0 4, -3 3, -8 6, -6 8, -2 9, 0 4))",
170+
"POLYGON ((10 3, 10 6, 14 6, 14 3, 10 3))",
171+
"POLYGON ((2 2, 2 4, 3 5, 7 5, 9 3, 8 1, 4 1, 2 2))",
172+
"POLYGON ((-1 -1, -1 -3, -2 -5, -6 -8, -5 -2, -3 -2, -1 -1))",
173+
"POLYGON ((-1 -1, -1 -3, -2 -5, -6 -8, -5 -2, -3 -2, -1 -1))",
174+
}
175+
assert {geom[0] for geom in right_geometries} == {
176+
"POINT (-3 5)",
177+
"POINT (11 5)",
178+
"POINT (4 3)",
179+
"POINT (-1 -1)",
180+
"POINT (-4 -5)",
181+
}
186182

187183
def test_range_query_flat_to_df(self):
188184
poi_point_rdd = WktReader.readToGeometryRDD(

python/tests/sql/test_function.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -1911,14 +1911,10 @@ def test_st_collect_on_array_type(self):
19111911
)
19121912

19131913
# then result should be as expected
1914-
assert set(
1915-
[
1916-
el[0]
1917-
for el in geometry_df_collected.selectExpr(
1918-
"ST_AsText(collected)"
1919-
).collect()
1920-
]
1921-
) == {
1914+
assert {
1915+
el[0]
1916+
for el in geometry_df_collected.selectExpr("ST_AsText(collected)").collect()
1917+
} == {
19221918
"MULTILINESTRING ((1 2, 3 4), (3 4, 4 5))",
19231919
"MULTIPOINT ((1 2), (-2 3))",
19241920
"MULTIPOLYGON (((1 2, 1 4, 3 4, 3 2, 1 2)), ((0.5 0.5, 5 0, 5 5, 0 5, 0.5 0.5)))",
@@ -1944,14 +1940,10 @@ def test_st_collect_on_multiple_columns(self):
19441940
)
19451941

19461942
# then result should be calculated
1947-
assert set(
1948-
[
1949-
el[0]
1950-
for el in geometry_df_collected.selectExpr(
1951-
"ST_AsText(collected)"
1952-
).collect()
1953-
]
1954-
) == {
1943+
assert {
1944+
el[0]
1945+
for el in geometry_df_collected.selectExpr("ST_AsText(collected)").collect()
1946+
} == {
19551947
"MULTILINESTRING ((1 2, 3 4), (3 4, 4 5))",
19561948
"MULTIPOINT ((1 2), (-2 3))",
19571949
"MULTIPOLYGON (((1 2, 1 4, 3 4, 3 2, 1 2)), ((0.5 0.5, 5 0, 5 5, 0 5, 0.5 0.5)))",

python/tests/stats/test_dbscan.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def get_actual_results(
9292

9393
clusters = {
9494
frozenset([y[0] for y in clusters_members if y[1] == x])
95-
for x in set([y[1] for y in clusters_members])
95+
for x in {y[1] for y in clusters_members}
9696
}
9797

9898
return clusters

0 commit comments

Comments
 (0)