From 8440048b06643f6fdfeaeadac7e3f86acf9a217b Mon Sep 17 00:00:00 2001 From: John Bampton Date: Sat, 12 Oct 2024 09:12:03 +1000 Subject: [PATCH 1/5] [CI] Add pre-commit hook `vulture` to find dead Python code https://github.com/jendrikseipp/vulture?tab=readme-ov-file#configuration https://github.com/jendrikseipp/vulture?tab=readme-ov-file#integrations --- .pre-commit-config.yaml | 5 +++++ pyproject.toml | 4 ++++ python/sedona/maps/SedonaPyDeck.py | 2 +- python/sedona/raster/sedona_raster.py | 2 +- python/sedona/utils/abstract_parser.py | 2 +- python/sedona/utils/spatial_rdd_parser.py | 8 ++++---- python/tests/spatial_rdd/test_spatial_rdd_writer.py | 2 +- 7 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 69dd4cb295..4de48f312f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,6 +10,11 @@ repos: hooks: - id: identity - id: check-hooks-apply + - repo: https://github.com/jendrikseipp/vulture + rev: v2.13 + hooks: + - id: vulture + args: [--min-confidence=100] - repo: https://github.com/psf/black-pre-commit-mirror rev: 24.10.0 hooks: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..882798f587 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.vulture] +min_confidence = 100 +paths = ["python/", "spark-version-converter.py", "docs/usecases/utilities.py"] +sort_by_size = true diff --git a/python/sedona/maps/SedonaPyDeck.py b/python/sedona/maps/SedonaPyDeck.py index 367fffc9c5..444aa6f620 100644 --- a/python/sedona/maps/SedonaPyDeck.py +++ b/python/sedona/maps/SedonaPyDeck.py @@ -318,7 +318,7 @@ def _create_default_fill_color_(cls, gdf, plot_col): return "[85, 183, 177, ({0} / {1}) * 255 + 15]".format(plot_col, plot_max) @classmethod - def _create_coord_column_(cls, gdf, geometry_col, add_points=False): + def _create_coord_column_(cls, gdf, geometry_col): """ Create a coordinate column in a given GeoPandas Dataframe, this coordinate column contains coordinates of a ST_Point in a list format of [longitude, latitude] :param gdf: GeoPandas Dataframe diff --git a/python/sedona/raster/sedona_raster.py b/python/sedona/raster/sedona_raster.py index 4520950edc..c25475db44 100644 --- a/python/sedona/raster/sedona_raster.py +++ b/python/sedona/raster/sedona_raster.py @@ -191,7 +191,7 @@ def close(self): def __enter__(self): return self - def __exit__(self, exc_type, exc_val, exc_tb): + def __exit__(self): self.close() def __del__(self): diff --git a/python/sedona/utils/abstract_parser.py b/python/sedona/utils/abstract_parser.py index fdf3a067c5..e746576056 100644 --- a/python/sedona/utils/abstract_parser.py +++ b/python/sedona/utils/abstract_parser.py @@ -29,7 +29,7 @@ def name(self): raise NotImplementedError @classmethod - def serialize(cls, obj: BaseGeometry, binary_buffer: "BinaryBuffer"): + def serialize(cls, obj: BaseGeometry): raise NotImplementedError("Parser has to implement serialize method") @classmethod diff --git a/python/sedona/utils/spatial_rdd_parser.py b/python/sedona/utils/spatial_rdd_parser.py index c18ac9cd8c..6ce29de7e9 100644 --- a/python/sedona/utils/spatial_rdd_parser.py +++ b/python/sedona/utils/spatial_rdd_parser.py @@ -101,7 +101,7 @@ def __ne__(self, other): class AbstractSpatialRDDParser(ABC): @classmethod - def serialize(cls, obj: List[Any], binary_buffer: "BinaryBuffer") -> bytearray: + def serialize(cls, obj: List[Any]) -> bytearray: raise NotImplemented() @classmethod @@ -131,7 +131,7 @@ def deserialize(cls, bin_parser: "BinaryParser"): return deserialized_data @classmethod - def serialize(cls, obj: BaseGeometry, binary_buffer: "BinaryBuffer"): + def serialize(cls, obj: BaseGeometry): raise NotImplementedError("Currently this operation is not supported") @@ -147,7 +147,7 @@ def deserialize(cls, bin_parser: "BinaryParser"): return left_geom_data @classmethod - def serialize(cls, obj: BaseGeometry, binary_buffer: "BinaryBuffer"): + def serialize(cls, obj: BaseGeometry): raise NotImplementedError("Currently this operation is not supported") @@ -174,7 +174,7 @@ def deserialize(cls, bin_parser: "BinaryParser"): return deserialized_data @classmethod - def serialize(cls, obj: BaseGeometry, binary_buffer: "BinaryBuffer"): + def serialize(cls, obj: BaseGeometry): raise NotImplementedError("Currently this operation is not supported") diff --git a/python/tests/spatial_rdd/test_spatial_rdd_writer.py b/python/tests/spatial_rdd/test_spatial_rdd_writer.py index 334a7d1485..85a376e851 100644 --- a/python/tests/spatial_rdd/test_spatial_rdd_writer.py +++ b/python/tests/spatial_rdd/test_spatial_rdd_writer.py @@ -74,7 +74,7 @@ def remove_wkb_directory(): class TestSpatialRDDWriter(TestBase): - def test_save_as_geo_json_with_data(self, remove_wkb_directory): + def test_save_as_geo_json_with_data(self): spatial_rdd = PointRDD( sparkContext=self.sc, InputLocation=inputLocation, From 713a7854131b0a656c07964ddca660bcc4085557 Mon Sep 17 00:00:00 2001 From: John Bampton Date: Sat, 12 Oct 2024 09:40:20 +1000 Subject: [PATCH 2/5] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 882798f587..331390425a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [tool.vulture] min_confidence = 100 -paths = ["python/", "spark-version-converter.py", "docs/usecases/utilities.py"] +paths = ["docs/usecases/utilities.py", "python/", "spark-version-converter.py"] sort_by_size = true From 7ba3e7cff418f34519ef77a486aca40929deb2a3 Mon Sep 17 00:00:00 2001 From: John Bampton Date: Sat, 12 Oct 2024 09:40:30 +1000 Subject: [PATCH 3/5] Update python/sedona/raster/sedona_raster.py --- python/sedona/raster/sedona_raster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/sedona/raster/sedona_raster.py b/python/sedona/raster/sedona_raster.py index c25475db44..4520950edc 100644 --- a/python/sedona/raster/sedona_raster.py +++ b/python/sedona/raster/sedona_raster.py @@ -191,7 +191,7 @@ def close(self): def __enter__(self): return self - def __exit__(self): + def __exit__(self, exc_type, exc_val, exc_tb): self.close() def __del__(self): From c2b1692237cf1ce8604835b4e7ab305363396ad3 Mon Sep 17 00:00:00 2001 From: John Bampton Date: Sat, 12 Oct 2024 10:04:33 +1000 Subject: [PATCH 4/5] Fix up noqa --- python/sedona/raster/sedona_raster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/sedona/raster/sedona_raster.py b/python/sedona/raster/sedona_raster.py index 4520950edc..b8f091e80a 100644 --- a/python/sedona/raster/sedona_raster.py +++ b/python/sedona/raster/sedona_raster.py @@ -191,7 +191,7 @@ def close(self): def __enter__(self): return self - def __exit__(self, exc_type, exc_val, exc_tb): + def __exit__(self, exc_type, exc_val, exc_tb): # noqa self.close() def __del__(self): From 216f2fbc10b892379640d4fb919cea2305c091e5 Mon Sep 17 00:00:00 2001 From: John Bampton Date: Sat, 12 Oct 2024 10:35:19 +1000 Subject: [PATCH 5/5] Fix up --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4de48f312f..728efd3ac1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,6 @@ repos: rev: v2.13 hooks: - id: vulture - args: [--min-confidence=100] - repo: https://github.com/psf/black-pre-commit-mirror rev: 24.10.0 hooks: