Skip to content

Commit a3436b7

Browse files
committed
Ruff checked and formatted.
1 parent d72f16e commit a3436b7

File tree

12 files changed

+88
-27
lines changed

12 files changed

+88
-27
lines changed

src/shapefile/__init__.py

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,37 @@
88

99
from __future__ import annotations
1010

11-
__all__ = [
12-
"__version__"
13-
14-
]
15-
1611
import logging
1712
import sys
1813

1914
from .__version__ import __version__
2015
from ._doctest_runner import _test
21-
22-
23-
logger = logging.getLogger(__name__)
24-
2516
from .helpers import _Array, fsdecode_if_pathlike
2617
from .reader import Reader
2718
from .shapes import (
19+
SHAPE_CLASS_FROM_SHAPETYPE,
20+
MultiPatch,
21+
MultiPoint,
22+
MultiPointM,
23+
MultiPointZ,
2824
NullShape,
2925
Point,
26+
PointM,
27+
PointM_shapeTypes,
28+
PointZ,
29+
PointZ_shapeTypes,
3030
Polygon,
31-
# ...add other shape classes as needed
31+
PolygonM,
32+
PolygonZ,
3233
Polyline,
34+
PolylineM,
35+
PolylineZ,
3336
Shape,
37+
_CanHaveBBox_shapeTypes,
38+
_HasM,
39+
_HasM_shapeTypes,
40+
_HasZ,
41+
_HasZ_shapeTypes,
3442
)
3543
from .types import (
3644
FIELD_TYPE_ALIASES,
@@ -58,6 +66,61 @@
5866
ZBox,
5967
)
6068

69+
__all__ = [
70+
"__version__",
71+
"Reader",
72+
"fsdecode_if_pathlike",
73+
"_Array",
74+
"Shape",
75+
"NullShape",
76+
"Point",
77+
"Polyline",
78+
"Polygon",
79+
"MultiPoint",
80+
"MultiPointM",
81+
"MultiPointZ",
82+
"PolygonM",
83+
"PolygonZ",
84+
"PolylineM",
85+
"PolylineZ",
86+
"MultiPatch",
87+
"PointM",
88+
"PointZ",
89+
"SHAPE_CLASS_FROM_SHAPETYPE",
90+
"PointM_shapeTypes",
91+
"PointZ_shapeTypes",
92+
"_CanHaveBBox_shapeTypes",
93+
"_HasM",
94+
"_HasM_shapeTypes",
95+
"_HasZ",
96+
"_HasZ_shapeTypes",
97+
"Point2D",
98+
"Point3D",
99+
"PointMT",
100+
"PointZT",
101+
"Coord",
102+
"Coords",
103+
"PointT",
104+
"PointsT",
105+
"BBox",
106+
"MBox",
107+
"ZBox",
108+
"WriteableBinStream",
109+
"ReadableBinStream",
110+
"WriteSeekableBinStream",
111+
"ReadSeekableBinStream",
112+
"ReadWriteSeekableBinStream",
113+
"BinaryFileT",
114+
"BinaryFileStreamT",
115+
"FieldTypeT",
116+
"FieldType",
117+
"FIELD_TYPE_ALIASES",
118+
"RecordValueNotDate",
119+
"RecordValue",
120+
]
121+
122+
logger = logging.getLogger(__name__)
123+
61124

62125
def main() -> None:
63126
"""

src/shapefile/__version__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
2-
__version__ = "3.0.2"
1+
__version__ = "3.0.2"

src/shapefile/_doctest_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ def _test(args: list[str] = sys.argv[1:], verbosity: bool = False) -> int:
144144
elif failure_count > 0:
145145
runner.summarize(verbosity)
146146

147-
return failure_count
147+
return failure_count

src/shapefile/classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,4 @@ def __geo_interface__(self) -> GeoJSONFeatureCollection:
283283
return GeoJSONFeatureCollection(
284284
type="FeatureCollection",
285285
features=[shaperec.__geo_interface__ for shaperec in self],
286-
)
286+
)

src/shapefile/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@
6161

6262

6363
MISSING = (None, "") # Don't make a set, as user input may not be Hashable
64-
NODATA = -10e38 # as per the ESRI shapefile spec, only used for m-values.
64+
NODATA = -10e38 # as per the ESRI shapefile spec, only used for m-values.

src/shapefile/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
21
class RingSamplingError(Exception):
32
pass
43

4+
55
class GeoJSON_Error(Exception):
66
pass
77

8+
89
class ShapefileException(Exception):
910
"""An exception to handle shapefile specific problems."""
10-

src/shapefile/geojson.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
from .types import PointsT, PointT
2626

2727
logger = logging.getLogger(__name__)
28-
28+
29+
2930
class HasGeoInterface(Protocol):
3031
@property
3132
def __geo_interface__(self) -> GeoJSONHomogeneousGeometryObject: ...
@@ -119,6 +120,7 @@ class GeoJSONFeatureCollectionWithBBox(GeoJSONFeatureCollection):
119120
# (PyShp's resisted having any other dependencies so far!)
120121
bbox: list[float]
121122

123+
122124
class GeoJSONSerisalizableShape:
123125
@property
124126
def __geo_interface__(self) -> GeoJSONHomogeneousGeometryObject:
@@ -301,4 +303,4 @@ def _from_geojson(cls, geoj: GeoJSONHomogeneousGeometryObject) -> Self:
301303
points.extend(ext_or_hole)
302304
parts.append(index)
303305
index += len(ext_or_hole)
304-
return cls(shapeType=shapeType, points=points, parts=parts)
306+
return cls(shapeType=shapeType, points=points, parts=parts)

src/shapefile/geometric_calculations.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ def ring_contains_point(coords: PointsT, p: Point2D) -> bool:
105105
return inside_flag
106106

107107

108-
109-
110108
def ring_sample(coords: PointsT, ccw: bool = False) -> Point2D:
111109
"""Return a sample point guaranteed to be within a ring, by efficiently
112110
finding the first centroid of a coordinate triplet whose orientation
@@ -288,4 +286,4 @@ def organize_polygon_rings(
288286
exteriors = holes
289287
# add as single exterior without any holes
290288
polys = [[ext] for ext in exteriors]
291-
return polys
289+
return polys

src/shapefile/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ class _Array(array.array, Generic[ARR_TYPE]): # type: ignore[type-arg]
3535
Used to unpack different shapefile header parts."""
3636

3737
def __repr__(self) -> str:
38-
return str(self.tolist())
38+
return str(self.tolist())

src/shapefile/shapes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ class CanHaveBboxNoLinesKwargs(TypedDict, total=False):
8484
z: Sequence[float] | None
8585
mbox: MBox | None
8686
zbox: ZBox | None
87+
88+
8789
class Shape(GeoJSONSerisalizableShape):
8890
def __init__(
8991
self,
@@ -256,8 +258,6 @@ def _mbox_from_ms(self) -> MBox:
256258
def _zbox_from_zs(self) -> ZBox:
257259
return min(self.z), max(self.z)
258260

259-
260-
261261
@property
262262
def oid(self) -> int:
263263
"""The index position of the shape in the original shapefile"""

0 commit comments

Comments
 (0)