Skip to content

Commit

Permalink
ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Dec 3, 2024
1 parent 300b12f commit d347428
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-all-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
- name: Linting
run: |
flake8 pygeoif
black --check pygeoif tests
ruff format --check pygeoif tests
ruff check --no-fix pygeoif tests
yamllint .github/workflows/
- name: Check complexity
Expand Down
5 changes: 2 additions & 3 deletions pygeoif/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#
# file deepcode ignore inconsistent~equality: Python 3 only
"""Features."""

from typing import Any
from typing import Dict
from typing import Generator
Expand Down Expand Up @@ -229,9 +230,7 @@ def __geo_interface__(self) -> GeoFeatureCollectionInterface:

def _check_interface(self, other: object) -> bool:
try:
return self.__geo_interface__[
"type"
] == other.__geo_interface__.get( # type: ignore [attr-defined]
return self.__geo_interface__["type"] == other.__geo_interface__.get( # type: ignore [attr-defined]
"type",
) and len(
self.__geo_interface__["features"],
Expand Down
1 change: 1 addition & 0 deletions pygeoif/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
"""Functions for geometries."""

import math
from itertools import groupby
from itertools import zip_longest
Expand Down
19 changes: 6 additions & 13 deletions pygeoif/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import math
import warnings
from itertools import chain
from typing import Any
from typing import Hashable
from typing import Iterable
Expand Down Expand Up @@ -859,10 +858,8 @@ def _from_dict(cls, geo_interface: GeoInterface) -> "MultiLineString":
return cls(cast(Sequence[LineType], geo_interface["coordinates"]))

def _prepare_hull(self) -> Iterable[Point2D]:
return (
(pt.x, pt.y)
for pt in chain.from_iterable(line.geoms for line in self.geoms)
)
for geom in self.geoms:
yield from geom._prepare_hull() # noqa: SLF001


class MultiPolygon(_MultiGeometry):
Expand Down Expand Up @@ -970,10 +967,8 @@ def _from_dict(cls, geo_interface: GeoInterface) -> "MultiPolygon":
return cls(cast(Sequence[PolygonType], coords))

def _prepare_hull(self) -> Iterable[Point2D]:
return (
(pt.x, pt.y)
for pt in chain.from_iterable(poly.exterior.geoms for poly in self.geoms)
)
for geom in self.geoms:
yield from geom._prepare_hull() # noqa: SLF001


Geometry = Union[
Expand Down Expand Up @@ -1091,10 +1086,8 @@ def __geo_interface__(self) -> GeoCollectionInterface: # type: ignore [override
}

def _prepare_hull(self) -> Iterable[Point2D]:
return chain.from_iterable(
geom._prepare_hull() # noqa: SLF001
for geom in self.geoms
)
for geom in self.geoms:
yield from geom._prepare_hull() # noqa: SLF001


__all__ = [
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ per-file-ignores =
tests/test_feature.py: ECE001,S10,D10,S307,DALL000,PT009,T003,P103
pygeoif/*: S604
pygeoif/types.py: A003
pygeoif/feature.py: E501
mutmut_config.py: TYP001
kwargs_ignore_function_pattern_extend = '^cast$'
literal_inline_quotes = double
Expand Down

0 comments on commit d347428

Please sign in to comment.