From 174314290f1113a2359a388d601d02a6bf263938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Lie=20Rapp?= <90246213+Bjoern-Rapp@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:00:46 +0200 Subject: [PATCH] =?UTF-8?q?Rettet=20p=C3=A5=20typehint.=20Dette=20fikser?= =?UTF-8?q?=20#161.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sgis/geopandas_tools/bounds.py | 5 +++-- src/sgis/geopandas_tools/duplicates.py | 2 +- src/sgis/geopandas_tools/general.py | 5 +++-- src/sgis/helpers.py | 2 +- src/sgis/io/write_municipality_data.py | 2 +- src/sgis/maps/explore.py | 2 +- src/sgis/parallel/parallel.py | 8 ++++---- src/sgis/raster/raster.py | 2 +- src/sgis/raster/zonal.py | 2 +- 9 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/sgis/geopandas_tools/bounds.py b/src/sgis/geopandas_tools/bounds.py index 5889eee7..d2c672d6 100644 --- a/src/sgis/geopandas_tools/bounds.py +++ b/src/sgis/geopandas_tools/bounds.py @@ -1,5 +1,6 @@ import numbers -from typing import Any, Callable, Iterable +from typing import Any +from collections.abc import Callable, Collection, Mapping import geopandas as gpd import numpy as np @@ -439,7 +440,7 @@ def bounds_to_points( def to_bbox( - obj: GeoDataFrame | GeoSeries | Geometry | Iterable | dict, + obj: GeoDataFrame | GeoSeries | Geometry | Collection | Mapping, ) -> tuple[float, float, float, float]: """Returns 4-length tuple of bounds if possible, else raises ValueError. diff --git a/src/sgis/geopandas_tools/duplicates.py b/src/sgis/geopandas_tools/duplicates.py index 5a75faea..5aea1b34 100644 --- a/src/sgis/geopandas_tools/duplicates.py +++ b/src/sgis/geopandas_tools/duplicates.py @@ -1,4 +1,4 @@ -from typing import Callable, Iterable +from collections.abc import Iterable import networkx as nx import pandas as pd diff --git a/src/sgis/geopandas_tools/general.py b/src/sgis/geopandas_tools/general.py index d185acfd..eeb050ac 100644 --- a/src/sgis/geopandas_tools/general.py +++ b/src/sgis/geopandas_tools/general.py @@ -1,6 +1,7 @@ import numbers import warnings -from typing import Any, Iterable +from typing import Any +from collections.abc import Iterable, Hashable import numpy as np import pandas as pd @@ -22,7 +23,7 @@ from .geometry_types import get_geom_type, make_all_singlepart, to_single_geom_type -def get_common_crs(iterable: Iterable[Any], strict: bool = False) -> pyproj.CRS | None: +def get_common_crs(iterable: Iterable[Hashable], strict: bool = False) -> pyproj.CRS | None: """Returns the common not-None crs or raises a ValueError if more than one. Args: diff --git a/src/sgis/helpers.py b/src/sgis/helpers.py index e550c02c..6eb9b621 100644 --- a/src/sgis/helpers.py +++ b/src/sgis/helpers.py @@ -3,7 +3,7 @@ import inspect import os import warnings -from typing import Callable +from collections.abc import Callable import numpy as np from geopandas import GeoDataFrame diff --git a/src/sgis/io/write_municipality_data.py b/src/sgis/io/write_municipality_data.py index 6a99508b..95c0dde4 100644 --- a/src/sgis/io/write_municipality_data.py +++ b/src/sgis/io/write_municipality_data.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import Callable +from collections.abc import Callable import pandas as pd from dapla import write_pandas diff --git a/src/sgis/maps/explore.py b/src/sgis/maps/explore.py index 75a89941..e21031d0 100644 --- a/src/sgis/maps/explore.py +++ b/src/sgis/maps/explore.py @@ -7,7 +7,7 @@ import warnings from numbers import Number from statistics import mean -from typing import Iterable +from collections.abc import Iterable import branca as bc import folium diff --git a/src/sgis/parallel/parallel.py b/src/sgis/parallel/parallel.py index 15912db6..3dbd1ba8 100644 --- a/src/sgis/parallel/parallel.py +++ b/src/sgis/parallel/parallel.py @@ -2,8 +2,8 @@ import itertools import multiprocessing from pathlib import Path -from typing import Any, Callable, Iterable, Sized - +from typing import Any +from collections.abc import Collection, Callable, Iterable try: import dapla as dp @@ -73,7 +73,7 @@ def __init__( def map( self, func: Callable, - iterable: Iterable, + iterable: Collection, kwargs: dict | None = None, ) -> list[Any]: """Run functions in parallel with items of an iterable as first arguemnt. @@ -151,7 +151,7 @@ def map( def starmap( self, func: Callable, - iterable: Iterable[Iterable[Any]], + iterable: Collection[Iterable[Any]], kwargs: dict | None = None, ) -> list[Any]: """Run functions in parallel where items of the iterable are unpacked. diff --git a/src/sgis/raster/raster.py b/src/sgis/raster/raster.py index a70db71b..eb2b04fe 100644 --- a/src/sgis/raster/raster.py +++ b/src/sgis/raster/raster.py @@ -5,7 +5,7 @@ from copy import copy, deepcopy from json import loads from pathlib import Path -from typing import Callable +from collections.abc import Callable import geopandas as gpd import matplotlib.pyplot as plt diff --git a/src/sgis/raster/zonal.py b/src/sgis/raster/zonal.py index 7dedcc7b..20dd4dc1 100644 --- a/src/sgis/raster/zonal.py +++ b/src/sgis/raster/zonal.py @@ -1,4 +1,4 @@ -from typing import Callable +from collections.abc import Callable import geopandas as gpd import numpy as np