timwie / aio-overpass

Async client for the Overpass API
https://pypi.org/project/aio-overpass/
MIT License
4 stars 1 forks source link

Fix `pyright` errors #16

Closed timwie closed 3 months ago

timwie commented 4 months ago

Updating pyright introduced a number of new error reports:


https://github.com/timwie/aio-overpass/blob/868443de2958cc9353b31ee3bbf128d62a9d4298/aio_overpass/element.py#L237

  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/element.py:351:5 - error: "geometry" overrides symbol of same name in class "Element"
    Variable is mutable so its type is invariant
      Override type "Point | None" is not the same as base type "BaseGeometry | None" (reportIncompatibleVariableOverride)
  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/element.py:377:5 - error: "geometry" overrides symbol of same name in class "Element"
    Variable is mutable so its type is invariant
      Override type "LineString | LinearRing | Polygon | None" is not the same as base type "BaseGeometry | None" (reportIncompatibleVariableOverride)
  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/element.py:416:5 - error: "geometry" overrides symbol of same name in class "Element"
    Variable is mutable so its type is invariant
      Override type "Polygon | MultiPolygon | None" is not the same as base type "BaseGeometry | None" (reportIncompatibleVariableOverride)

My intention with adding the geometry property to Element was to emulate an abstract property, that all the subclasses need to extend with some BaseGeometry. pyright is right to complain here though.


https://github.com/timwie/aio-overpass/blob/868443de2958cc9353b31ee3bbf128d62a9d4298/aio_overpass/element.py#L613-L651

  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/element.py:623:49 - error: Argument of type "GeometrySequence[MultiPolygon*]*" cannot be assigned to parameter "geometries" of type "OptGeoArrayLike" in function "intersection_all"
    Type "GeometrySequence[MultiPolygon*]*" is incompatible with type "OptGeoArrayLike"
      "GeometrySequence[MultiPolygon*]*" is incompatible with "Geometry"
      "GeometrySequence[MultiPolygon*]*" is incompatible with "None"
      "GeometrySequence[MultiPolygon*]*" is incompatible with protocol "SupportsArray[dtype[Any]]"
        "__array__" is not present
      "GeometrySequence[MultiPolygon*]*" is incompatible with "Sequence[SupportsArray[dtype[Any]]]"
      "GeometrySequence[MultiPolygon*]*" is incompatible with "Sequence[Sequence[SupportsArray[dtype[Any]]]]"
      "GeometrySequence[MultiPolygon*]*" is incompatible with "Sequence[Sequence[Sequence[SupportsArray[dtype[Any]]]]]"
    ... (reportArgumentType)

  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/element.py:636:20 - error: Expression of type "GeometryDetails[Polygon]" is incompatible with return type "GeometryDetails[G@_try_validate_geometry]"
    "GeometryDetails[Polygon]" is incompatible with "GeometryDetails[G@_try_validate_geometry]"
      Type parameter "G@GeometryDetails" is invariant, but "Polygon" is not the same as "G@_try_validate_geometry" (reportReturnType)

  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/element.py:645:20 - error: Expression of type "GeometryDetails[MultiPolygon]" is incompatible with return type "GeometryDetails[G@_try_validate_geometry]"
    "GeometryDetails[MultiPolygon]" is incompatible with "GeometryDetails[G@_try_validate_geometry]"
      Type parameter "G@GeometryDetails" is invariant, but "MultiPolygon" is not the same as "G@_try_validate_geometry" (reportReturnType)


https://github.com/timwie/aio-overpass/blob/868443de2958cc9353b31ee3bbf128d62a9d4298/aio_overpass/element.py#L705-L711

  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/element.py:709:27 - error: Argument of type "BaseGeometry" cannot be assigned to parameter "shell" of type "_PolygonShellLike" in function "__new__"
    Type "BaseGeometry" is incompatible with type "_PolygonShellLike"
      "BaseGeometry" is incompatible with "Polygon"
      "BaseGeometry" is incompatible with "LineString"
      "BaseGeometry" is incompatible with protocol "SupportsArray[dtype[Any]]"
        "__array__" is not present
      "BaseGeometry" is incompatible with "Sequence[SupportsArray[dtype[Any]]]"
      "BaseGeometry" is incompatible with "Sequence[Sequence[SupportsArray[dtype[Any]]]]"
      "BaseGeometry" is incompatible with "Sequence[Sequence[Sequence[SupportsArray[dtype[Any]]]]]"
    ... (reportArgumentType)
  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/element.py:709:40 - error: Argument of type "list[BaseGeometry]" cannot be assigned to parameter "holes" of type "_PolygonHolesLike" in function "__new__" (reportArgumentType)



https://github.com/timwie/aio-overpass/blob/868443de2958cc9353b31ee3bbf128d62a9d4298/aio_overpass/pt_ordered.py#L216-L227

  /home/runner/work/aio-overpass/aio-overpass/aio_overpass/pt_ordered.py:225:53 - error: Expression of type "Generator[Iterator[LineString | None], None, None]" is incompatible with declared type "Iterator[Iterator[LineString]]"
    "Generator[Iterator[LineString | None], None, None]" is incompatible with "Iterator[Iterator[LineString]]"
      Type parameter "_T_co@Iterator" is covariant, but "Iterator[LineString | None]" is not a subtype of "Iterator[LineString]"
        "Iterator[LineString | None]" is incompatible with "Iterator[LineString]"
          Type parameter "_T_co@Iterator" is covariant, but "LineString | None" is not a subtype of "LineString"
            Type "LineString | None" is incompatible with type "LineString" (reportAssignmentType)
timwie commented 3 months ago

Removed pyright in 476773c. There's too many errors that are tricky to "fix" without resorting to ignore comments.