Skip to content

Commit f5752a0

Browse files
committed
Replace .append on trivial list comps with .extend. Remove more elses.
1 parent 0eb6a68 commit f5752a0

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/shapefile.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -552,13 +552,13 @@ def __geo_interface__(self) -> GeoJsonShapeT:
552552
if ps is None:
553553
ps = part
554554
continue
555-
else:
556-
# coordinates.append([tuple(p) for p in self.points[ps:part]])
557-
coordinates.append([p for p in self.points[ps:part]])
558-
ps = part
555+
556+
# coordinates.append([tuple(p) for p in self.points[ps:part]])
557+
coordinates.extend(self.points[ps:part])
558+
ps = part
559559

560560
# coordinates.append([tuple(p) for p in self.points[part:]])
561-
coordinates.append([p for p in self.points[part:]]) # pylint: disable=undefined-loop-variable
561+
coordinates.extend(self.points[part:]) # pylint: disable=undefined-loop-variable
562562

563563
return {"type": "MultiLineString", "coordinates": coordinates}
564564

@@ -581,7 +581,7 @@ def __geo_interface__(self) -> GeoJsonShapeT:
581581

582582
# extract the points that make up the ring
583583
# ring = [tuple(p) for p in self.points[start:end]]
584-
ring = [p for p in self.points[start:end]]
584+
ring = list(self.points[start:end])
585585
rings.append(ring)
586586

587587
# organize rings into list of polygons, where each polygon is defined as list of rings.
@@ -813,8 +813,8 @@ def __getitem__(self, item):
813813
index = None
814814
if index is not None:
815815
return list.__getitem__(self, index)
816-
else:
817-
raise IndexError(f'"{item}" is not a field name and not an int')
816+
817+
raise IndexError(f'"{item}" is not a field name and not an int')
818818

819819
def __setitem__(self, key, value):
820820
"""
@@ -831,8 +831,8 @@ def __setitem__(self, key, value):
831831
index = self.__field_positions.get(key)
832832
if index is not None:
833833
return list.__setitem__(self, index, value)
834-
else:
835-
raise IndexError(f"{key} is not a field name and not an int") # pylint: disable=raise-missing-from
834+
835+
raise IndexError(f"{key} is not a field name and not an int") # pylint: disable=raise-missing-from
836836

837837
@property
838838
def oid(self) -> int:
@@ -937,7 +937,7 @@ class ShapefileException(Exception):
937937
"""An exception to handle shapefile specific problems."""
938938

939939

940-
class _NoShpSentinel(object):
940+
class _NoShpSentinel:
941941
"""For use as a default value for shp to preserve the
942942
behaviour (from when all keyword args were gathered
943943
in the **kwargs dict) in case someone explictly

0 commit comments

Comments
 (0)