Skip to content

Commit

Permalink
[CI] Add pre-commit hook pyupgrade to auto upgrade Python syntax
Browse files Browse the repository at this point in the history
"A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language."

https://github.com/asottile/pyupgrade
  • Loading branch information
jbampton committed Oct 13, 2024
1 parent c6d7969 commit bcea17e
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 39 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ repos:
hooks:
- id: identity
- id: check-hooks-apply
- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
hooks:
- id: pyupgrade
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion python/sedona/core/jvm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from sedona.utils.decorators import classproperty

string_types = (type(b""), type(""))
string_types = (bytes, str)


def is_greater_or_equal_version(version_a: str, version_b: str) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion python/sedona/maps/SedonaPyDeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _create_default_fill_color_(cls, gdf, plot_col):
:return: fill_color string for pydeck map
"""
plot_max = gdf[plot_col].max()
return "[85, 183, 177, ({0} / {1}) * 255 + 15]".format(plot_col, plot_max)
return "[85, 183, 177, ({} / {}) * 255 + 15]".format(plot_col, plot_max)

@classmethod
def _create_coord_column_(cls, gdf, geometry_col, add_points=False):
Expand Down
2 changes: 1 addition & 1 deletion python/sedona/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
T = TypeVar("T")


class classproperty(object):
class classproperty:

def __init__(self, f):
self.f = f
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from sedona import version

with open("README.md", "r") as fh:
with open("README.md") as fh:
long_description = fh.read()

extension_args = {}
Expand Down
32 changes: 14 additions & 18 deletions python/tests/core/test_avoiding_python_jvm_serde_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,20 @@ def test_spatial_join_query_flat_to_df(self):
right_geometries = self.__row_to_list(right_geometries_raw)

# Ignore the ordering of these
assert set(geom[0] for geom in left_geometries) == set(
[
"POLYGON ((0 4, -3 3, -8 6, -6 8, -2 9, 0 4))",
"POLYGON ((10 3, 10 6, 14 6, 14 3, 10 3))",
"POLYGON ((2 2, 2 4, 3 5, 7 5, 9 3, 8 1, 4 1, 2 2))",
"POLYGON ((-1 -1, -1 -3, -2 -5, -6 -8, -5 -2, -3 -2, -1 -1))",
"POLYGON ((-1 -1, -1 -3, -2 -5, -6 -8, -5 -2, -3 -2, -1 -1))",
]
)
assert set(geom[0] for geom in right_geometries) == set(
[
"POINT (-3 5)",
"POINT (11 5)",
"POINT (4 3)",
"POINT (-1 -1)",
"POINT (-4 -5)",
]
)
assert {geom[0] for geom in left_geometries} == {
"POLYGON ((0 4, -3 3, -8 6, -6 8, -2 9, 0 4))",
"POLYGON ((10 3, 10 6, 14 6, 14 3, 10 3))",
"POLYGON ((2 2, 2 4, 3 5, 7 5, 9 3, 8 1, 4 1, 2 2))",
"POLYGON ((-1 -1, -1 -3, -2 -5, -6 -8, -5 -2, -3 -2, -1 -1))",
"POLYGON ((-1 -1, -1 -3, -2 -5, -6 -8, -5 -2, -3 -2, -1 -1))",
}
assert {geom[0] for geom in right_geometries} == {
"POINT (-3 5)",
"POINT (11 5)",
"POINT (4 3)",
"POINT (-1 -1)",
"POINT (-4 -5)",
}

def test_range_query_flat_to_df(self):
poi_point_rdd = WktReader.readToGeometryRDD(
Expand Down
24 changes: 8 additions & 16 deletions python/tests/sql/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1911,14 +1911,10 @@ def test_st_collect_on_array_type(self):
)

# then result should be as expected
assert set(
[
el[0]
for el in geometry_df_collected.selectExpr(
"ST_AsText(collected)"
).collect()
]
) == {
assert {
el[0]
for el in geometry_df_collected.selectExpr("ST_AsText(collected)").collect()
} == {
"MULTILINESTRING ((1 2, 3 4), (3 4, 4 5))",
"MULTIPOINT ((1 2), (-2 3))",
"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)))",
Expand All @@ -1944,14 +1940,10 @@ def test_st_collect_on_multiple_columns(self):
)

# then result should be calculated
assert set(
[
el[0]
for el in geometry_df_collected.selectExpr(
"ST_AsText(collected)"
).collect()
]
) == {
assert {
el[0]
for el in geometry_df_collected.selectExpr("ST_AsText(collected)").collect()
} == {
"MULTILINESTRING ((1 2, 3 4), (3 4, 4 5))",
"MULTIPOINT ((1 2), (-2 3))",
"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)))",
Expand Down
2 changes: 1 addition & 1 deletion python/tests/stats/test_dbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_actual_results(

clusters = {
frozenset([y[0] for y in clusters_members if y[1] == x])
for x in set([y[1] for y in clusters_members])
for x in {y[1] for y in clusters_members}
}

return clusters
Expand Down

0 comments on commit bcea17e

Please sign in to comment.