33import abc
44import itertools
55import warnings
6+ from collections .abc import Sequence
67from threading import Lock
7- from typing import Any , Dict , List , Optional , Sequence , Type , Union
8+ from typing import Any
89
910import attr
1011from cachetools import TTLCache , cached
2526from cogeo_mosaic .utils import bbox_union
2627
2728
28- def _convert_to_mosaicjson (value : Union [ Dict , MosaicJSON ] ):
29+ def _convert_to_mosaicjson (value : dict | MosaicJSON ):
2930 if value is not None :
3031 return MosaicJSON (** dict (value ))
3132
@@ -55,18 +56,16 @@ class MosaicJSONBackend(BaseBackend):
5556 minzoom : int = attr .ib (default = None )
5657 maxzoom : int = attr .ib (default = None )
5758
58- reader : Union [
59- Type [BaseReader ],
60- Type [MultiBaseReader ],
61- Type [MultiBandReader ],
62- ] = attr .ib (default = Reader )
63- reader_options : Dict = attr .ib (factory = dict )
59+ reader : type [BaseReader ] | type [MultiBaseReader ] | type [MultiBandReader ] = attr .ib (
60+ default = Reader
61+ )
62+ reader_options : dict = attr .ib (factory = dict )
6463
6564 bounds : BBox = attr .ib (init = False )
6665 crs : CRS = attr .ib (init = False )
6766
6867 _backend_name : str
69- _file_byte_size : Optional [ int ] = 0
68+ _file_byte_size : int | None = 0
7069
7170 def __attrs_post_init__ (self ):
7271 """Post Init: if not passed in init, try to read from self.input."""
@@ -103,7 +102,7 @@ def write(self, overwrite: bool = True):
103102
104103 def update (
105104 self ,
106- features : Sequence [Dict ],
105+ features : Sequence [dict ],
107106 add_first : bool = True ,
108107 quiet : bool = False ,
109108 ** kwargs ,
@@ -146,7 +145,7 @@ def update(
146145 self .bounds = bounds
147146 self .write (overwrite = True )
148147
149- def assets_for_tile (self , x : int , y : int , z : int , ** kwargs : Any ) -> List [str ]:
148+ def assets_for_tile (self , x : int , y : int , z : int , ** kwargs : Any ) -> list [str ]:
150149 """Retrieve assets for tile."""
151150 mosaic_tms = self .mosaic_def .tilematrixset or WEB_MERCATOR_TMS
152151 if self .tms == mosaic_tms :
@@ -168,9 +167,9 @@ def assets_for_point(
168167 self ,
169168 lng : float ,
170169 lat : float ,
171- coord_crs : Optional [ CRS ] = None ,
170+ coord_crs : CRS | None = None ,
172171 ** kwargs : Any ,
173- ) -> List [str ]:
172+ ) -> list [str ]:
174173 """Retrieve assets for point."""
175174 mosaic_tms = self .mosaic_def .tilematrixset or WEB_MERCATOR_TMS
176175
@@ -196,9 +195,9 @@ def assets_for_bbox(
196195 ymin : float ,
197196 xmax : float ,
198197 ymax : float ,
199- coord_crs : Optional [ CRS ] = None ,
198+ coord_crs : CRS | None = None ,
200199 ** kwargs ,
201- ) -> List [str ]:
200+ ) -> list [str ]:
202201 """Retrieve assets for bbox."""
203202 mosaic_tms = self .mosaic_def .tilematrixset or WEB_MERCATOR_TMS
204203
@@ -241,7 +240,7 @@ def assets_for_bbox(
241240 ),
242241 lock = Lock (),
243242 )
244- def get_assets (self , x : int , y : int , z : int , reverse : bool = False ) -> List [str ]:
243+ def get_assets (self , x : int , y : int , z : int , reverse : bool = False ) -> list [str ]:
245244 """Find assets."""
246245 quadkeys = self .find_quadkeys (Tile (x = x , y = y , z = z ), self .quadkey_zoom )
247246 assets = list (
@@ -259,7 +258,7 @@ def get_assets(self, x: int, y: int, z: int, reverse: bool = False) -> List[str]
259258
260259 return assets
261260
262- def find_quadkeys (self , tile : Tile , quadkey_zoom : int ) -> List [str ]:
261+ def find_quadkeys (self , tile : Tile , quadkey_zoom : int ) -> list [str ]:
263262 """
264263 Find quadkeys at desired zoom for tile
265264
@@ -273,7 +272,7 @@ def find_quadkeys(self, tile: Tile, quadkey_zoom: int) -> List[str]:
273272 Returns
274273 -------
275274 list
276- List [str] of quadkeys
275+ list [str] of quadkeys
277276
278277 """
279278 mosaic_tms = self .mosaic_def .tilematrixset or WEB_MERCATOR_TMS
@@ -318,7 +317,7 @@ def mosaicid(self) -> str:
318317 return get_hash (** self .mosaic_def .model_dump (exclude_none = True ))
319318
320319 @property
321- def _quadkeys (self ) -> List [str ]:
320+ def _quadkeys (self ) -> list [str ]:
322321 """Return the list of quadkey tiles."""
323322 return list (self .mosaic_def .tiles )
324323
0 commit comments