Skip to content

Commit

Permalink
[CI] Add pre-commit hook isort to sort Python imports (#1633)
Browse files Browse the repository at this point in the history
"isort is a Python utility / library to sort imports alphabetically and automatically separate into sections and by type."

https://github.com/PyCQA/isort

https://pycqa.github.io/isort/docs/configuration/pre-commit.html

https://pycqa.github.io/isort/docs/configuration/black_compatibility.html
  • Loading branch information
jbampton authored Oct 13, 2024
1 parent 122ee72 commit 37f8132
Show file tree
Hide file tree
Showing 122 changed files with 448 additions and 454 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ repos:
rev: 24.10.0
hooks:
- id: black-jupyter
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.isort]
profile = "black"
6 changes: 2 additions & 4 deletions python/sedona/core/SpatialRDD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
# specific language governing permissions and limitations
# under the License.

from .point_rdd import PointRDD
from .circle_rdd import CircleRDD
from .linestring_rdd import LineStringRDD
from .point_rdd import PointRDD
from .polygon_rdd import PolygonRDD
from .rectangle_rdd import RectangleRDD
from .rectangle_rdd import SpatialRDD

from .rectangle_rdd import RectangleRDD, SpatialRDD

__all__ = [
"PolygonRDD",
Expand Down
6 changes: 3 additions & 3 deletions python/sedona/core/SpatialRDD/linestring_rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# specific language governing permissions and limitations
# under the License.

from pyspark import SparkContext, StorageLevel, RDD
from pyspark import RDD, SparkContext, StorageLevel

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD, JvmSpatialRDD
from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.core.enums import FileDataSplitter
from sedona.core.enums.file_data_splitter import FileSplitterJvm
from sedona.core.jvm.translate import PythonRddToJavaRDDAdapter
from sedona.core.SpatialRDD.spatial_rdd import JvmSpatialRDD, SpatialRDD
from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.utils.meta import MultipleMeta


Expand Down
8 changes: 4 additions & 4 deletions python/sedona/core/SpatialRDD/point_rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# specific language governing permissions and limitations
# under the License.

from pyspark import SparkContext, StorageLevel, RDD
from pyspark import RDD, SparkContext, StorageLevel

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD, JvmSpatialRDD
from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.core.enums.file_data_splitter import FileSplitterJvm, FileDataSplitter
from sedona.core.enums.file_data_splitter import FileDataSplitter, FileSplitterJvm
from sedona.core.jvm.translate import PythonRddToJavaRDDAdapter
from sedona.core.SpatialRDD.spatial_rdd import JvmSpatialRDD, SpatialRDD
from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.utils.meta import MultipleMeta


Expand Down
8 changes: 4 additions & 4 deletions python/sedona/core/SpatialRDD/polygon_rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# specific language governing permissions and limitations
# under the License.

from pyspark import SparkContext, StorageLevel, RDD
from pyspark import RDD, SparkContext, StorageLevel

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD, JvmSpatialRDD
from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.core.enums.file_data_splitter import FileSplitterJvm, FileDataSplitter
from sedona.core.enums.file_data_splitter import FileDataSplitter, FileSplitterJvm
from sedona.core.jvm.translate import PythonRddToJavaRDDAdapter
from sedona.core.SpatialRDD.spatial_rdd import JvmSpatialRDD, SpatialRDD
from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.utils.meta import MultipleMeta


Expand Down
6 changes: 3 additions & 3 deletions python/sedona/core/SpatialRDD/rectangle_rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
# specific language governing permissions and limitations
# under the License.

from pyspark import SparkContext, StorageLevel, RDD
from pyspark import RDD, SparkContext, StorageLevel

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD, JvmSpatialRDD
from sedona.core.enums.file_data_splitter import FileDataSplitter, FileSplitterJvm
from sedona.core.SpatialRDD.spatial_rdd import JvmSpatialRDD, SpatialRDD
from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.core.enums.file_data_splitter import FileSplitterJvm, FileDataSplitter
from sedona.utils.jvm import JvmStorageLevel
from sedona.utils.meta import MultipleMeta

Expand Down
13 changes: 6 additions & 7 deletions python/sedona/core/SpatialRDD/spatial_rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@
# under the License.

import pickle
from typing import Optional, List, Union
from typing import List, Optional, Union

import attr
from py4j.java_gateway import get_field
from pyspark import SparkContext, RDD
from pyspark import RDD, SparkContext, StorageLevel
from pyspark.sql import SparkSession
from pyspark import StorageLevel

from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.core.enums.grid_type import GridTypeJvm, GridType
from sedona.core.enums.index_type import IndexTypeJvm, IndexType
from sedona.core.enums.grid_type import GridType, GridTypeJvm
from sedona.core.enums.index_type import IndexType, IndexTypeJvm
from sedona.core.enums.spatial import SpatialType
from sedona.core.geom.envelope import Envelope
from sedona.core.jvm.translate import SedonaPythonConverter, JvmSedonaPythonConverter
from sedona.core.jvm.translate import JvmSedonaPythonConverter, SedonaPythonConverter
from sedona.core.SpatialRDD.spatial_rdd_factory import SpatialRDDFactory
from sedona.utils.decorators import require
from sedona.utils.jvm import JvmStorageLevel
from sedona.utils.spatial_rdd_parser import SedonaPickler
Expand Down
2 changes: 1 addition & 1 deletion python/sedona/core/formatMapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

from .geo_json_reader import GeoJsonReader
from .wkt_reader import WktReader
from .wkb_reader import WkbReader
from .wkt_reader import WktReader

__all__ = ["GeoJsonReader", "WktReader", "WkbReader"]
2 changes: 1 addition & 1 deletion python/sedona/core/formatMapper/disc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

from pyspark import SparkContext

from sedona.core.SpatialRDD import SpatialRDD, PolygonRDD, LineStringRDD, PointRDD
from sedona.core.jvm.translate import SpatialObjectLoaderAdapter
from sedona.core.SpatialRDD import LineStringRDD, PointRDD, PolygonRDD, SpatialRDD
from sedona.utils.decorators import require


Expand Down
4 changes: 2 additions & 2 deletions python/sedona/core/formatMapper/geo_json_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# specific language governing permissions and limitations
# under the License.

from pyspark import SparkContext, RDD
from pyspark import RDD, SparkContext

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.core.formatMapper.geo_reader import GeoDataReader
from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.utils.meta import MultipleMeta


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import attr
from pyspark import SparkContext

from sedona.core.SpatialRDD import PolygonRDD, PointRDD, LineStringRDD
from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.core.formatMapper.geo_reader import GeoDataReader
from sedona.core.SpatialRDD import LineStringRDD, PointRDD, PolygonRDD
from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.utils.meta import MultipleMeta


Expand Down
4 changes: 2 additions & 2 deletions python/sedona/core/formatMapper/wkb_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# specific language governing permissions and limitations
# under the License.

from pyspark import SparkContext, RDD
from pyspark import RDD, SparkContext

from sedona.core.SpatialRDD import SpatialRDD
from sedona.core.formatMapper.geo_reader import GeoDataReader
from sedona.core.SpatialRDD import SpatialRDD
from sedona.utils.meta import MultipleMeta


Expand Down
4 changes: 2 additions & 2 deletions python/sedona/core/formatMapper/wkt_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# specific language governing permissions and limitations
# under the License.

from pyspark import SparkContext, RDD
from pyspark import RDD, SparkContext

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.core.formatMapper.geo_reader import GeoDataReader
from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.utils.meta import MultipleMeta


Expand Down
1 change: 0 additions & 1 deletion python/sedona/core/geom/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import shapely


if shapely.__version__.startswith("2."):
from .shapely2.circle import Circle
else:
Expand Down
1 change: 0 additions & 1 deletion python/sedona/core/geom/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import shapely


if shapely.__version__.startswith("2."):
from .shapely2.envelope import Envelope
else:
Expand Down
6 changes: 3 additions & 3 deletions python/sedona/core/geom/shapely1/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
from math import sqrt

from shapely.geometry import (
Polygon,
Point,
LineString,
MultiLineString,
MultiPoint,
MultiPolygon,
MultiLineString,
Point,
Polygon,
)
from shapely.geometry.base import BaseGeometry

Expand Down
7 changes: 4 additions & 3 deletions python/sedona/core/geom/shapely1/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
# specific language governing permissions and limitations
# under the License.

from shapely.geometry import Polygon, Point
import math
import pickle

from shapely.geometry import Point, Polygon
from shapely.geometry.base import BaseGeometry

from sedona.utils.decorators import require
import math
import pickle


class Envelope(Polygon):
Expand Down
6 changes: 3 additions & 3 deletions python/sedona/core/geom/shapely2/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
from math import sqrt

from shapely.geometry import (
Polygon,
Point,
LineString,
MultiLineString,
MultiPoint,
MultiPolygon,
MultiLineString,
Point,
Polygon,
box,
)
from shapely.geometry.base import BaseGeometry
Expand Down
5 changes: 3 additions & 2 deletions python/sedona/core/geom/shapely2/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
# specific language governing permissions and limitations
# under the License.

import math
import pickle

from shapely.geometry import Polygon, box
from shapely.geometry.base import BaseGeometry

from sedona.utils.decorators import require
import math
import pickle


class Envelope(Polygon):
Expand Down
7 changes: 4 additions & 3 deletions python/sedona/core/jvm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
# specific language governing permissions and limitations
# under the License.

import functools
import inspect
import logging
import os
import warnings
from re import findall
from typing import Optional, Tuple

from py4j.protocol import Py4JJavaError
from pyspark.sql import SparkSession

from sedona.utils.decorators import classproperty
import functools
import inspect
import warnings

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

Expand Down
4 changes: 2 additions & 2 deletions python/sedona/core/spatialOperator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
# under the License.

from .join_query import JoinQuery
from .range_query import RangeQuery
from .knn_query import KNNQuery
from .join_query_raw import JoinQueryRaw
from .knn_query import KNNQuery
from .range_query import RangeQuery
from .range_query_raw import RangeQueryRaw

__all__ = ["JoinQuery", "RangeQuery", "KNNQuery", "JoinQueryRaw", "RangeQueryRaw"]
2 changes: 1 addition & 1 deletion python/sedona/core/spatialOperator/join_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

from pyspark import RDD

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.core.spatialOperator.join_params import JoinParams
from sedona.core.spatialOperator.join_query_raw import JoinQueryRaw
from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.utils.decorators import require


Expand Down
4 changes: 2 additions & 2 deletions python/sedona/core/spatialOperator/join_query_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# specific language governing permissions and limitations
# under the License.

from sedona.core.SpatialRDD import SpatialRDD
from sedona.core.spatialOperator.join_params import JoinParams
from sedona.core.spatialOperator.rdd import SedonaPairRDDList, SedonaPairRDD
from sedona.core.spatialOperator.rdd import SedonaPairRDD, SedonaPairRDDList
from sedona.core.SpatialRDD import SpatialRDD
from sedona.utils.decorators import require


Expand Down
2 changes: 1 addition & 1 deletion python/sedona/core/spatialOperator/knn_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import attr
from shapely.geometry.base import BaseGeometry

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.core.jvm.translate import JvmSedonaPythonConverter
from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.utils.binary_parser import BinaryParser
from sedona.utils.decorators import require
from sedona.utils.geometry_adapter import GeometryAdapter
Expand Down
2 changes: 1 addition & 1 deletion python/sedona/core/spatialOperator/range_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from shapely.geometry.base import BaseGeometry

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.core.spatialOperator.range_query_raw import RangeQueryRaw
from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.utils.decorators import require


Expand Down
2 changes: 1 addition & 1 deletion python/sedona/core/spatialOperator/range_query_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from shapely.geometry.base import BaseGeometry

from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.core.spatialOperator.rdd import SedonaPairRDD, SedonaRDD
from sedona.core.SpatialRDD.spatial_rdd import SpatialRDD
from sedona.utils.decorators import require
from sedona.utils.geometry_adapter import GeometryAdapter

Expand Down
2 changes: 1 addition & 1 deletion python/sedona/core/spatialOperator/rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

from pyspark import SparkContext, RDD
from pyspark import RDD, SparkContext

from sedona.core.jvm.translate import JvmSedonaPythonConverter
from sedona.utils.spatial_rdd_parser import SedonaPickler
Expand Down
1 change: 1 addition & 0 deletions python/sedona/maps/SedonaMapUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

import json

from sedona.sql.types import GeometryType


Expand Down
6 changes: 3 additions & 3 deletions python/sedona/maps/SedonaPyDeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
from types import ModuleType

from pyspark.sql.types import (
FloatType,
ByteType,
DecimalType,
DoubleType,
FloatType,
IntegerType,
LongType,
DecimalType,
ShortType,
ByteType,
)

from sedona.maps.SedonaMapUtils import SedonaMapUtils
Expand Down
Loading

0 comments on commit 37f8132

Please sign in to comment.