Skip to content

Commit f6ee228

Browse files
committed
formating
1 parent 86663c6 commit f6ee228

File tree

4 files changed

+43
-30
lines changed

4 files changed

+43
-30
lines changed

pctiler/pctiler/endpoints/item.py

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,23 @@ def map(
132132
)
133133

134134

135+
prefix = pc_tile_factory.operation_prefix
136+
137+
135138
# crop/feature endpoint compat with titiler<0.15 (`/crop` was renamed `/feature`)
136139
@pc_tile_factory.router.post(
137140
r"/crop",
138-
operation_id=f"{self.operation_prefix}postDataForGeoJSONCrop",
141+
operation_id=f"{prefix}postDataForGeoJSONCrop",
139142
**img_endpoint_params,
140143
)
141144
@pc_tile_factory.router.post(
142145
r"/crop.{format}",
143-
operation_id=f"{self.operation_prefix}postDataForGeoJSONWithFormatCrop",
146+
operation_id=f"{prefix}postDataForGeoJSONWithFormatCrop",
144147
**img_endpoint_params,
145148
)
146149
@pc_tile_factory.router.post(
147150
r"/crop/{width}x{height}.{format}",
148-
operation_id=f"{self.operation_prefix}postDataForGeoJSONWithSizesAndFormatCrop",
151+
operation_id=f"{prefix}postDataForGeoJSONWithSizesAndFormatCrop",
149152
**img_endpoint_params,
150153
)
151154
def geojson_crop( # type: ignore
@@ -156,7 +159,7 @@ def geojson_crop( # type: ignore
156159
format: Annotated[
157160
ImageType,
158161
Field(
159-
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg)."
162+
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg)." # noqa: F722,E501
160163
),
161164
] = None, # type: ignore[assignment]
162165
src_path=Depends(pc_tile_factory.path_dependency),
@@ -196,52 +199,56 @@ def geojson_crop( # type: ignore
196199
# /tiles endpoint compat with titiler<0.15, Optional `tileMatrixSetId`
197200
@pc_tile_factory.router.get(
198201
"/tiles/{z}/{x}/{y}",
199-
operation_id=f"{pc_tile_factory.operation_prefix}getWebMercatorQuadTile",
202+
operation_id=f"{prefix}getWebMercatorQuadTile",
200203
**img_endpoint_params,
201204
)
202205
@pc_tile_factory.router.get(
203206
"/tiles/{z}/{x}/{y}.{format}",
204-
operation_id=f"{pc_tile_factory.operation_prefix}getWebMercatorQuadTileWithFormat",
207+
operation_id=f"{prefix}getWebMercatorQuadTileWithFormat",
205208
**img_endpoint_params,
206209
)
207210
@pc_tile_factory.router.get(
208211
"/tiles/{z}/{x}/{y}@{scale}x",
209-
operation_id=f"{pc_tile_factory.operation_prefix}getWebMercatorQuadTileWithScale",
212+
operation_id=f"{prefix}getWebMercatorQuadTileWithScale",
210213
**img_endpoint_params,
211214
)
212215
@pc_tile_factory.router.get(
213216
"/tiles/{z}/{x}/{y}@{scale}x.{format}",
214-
operation_id=f"{pc_tile_factory.operation_prefix}getWebMercatorQuadTileWithFormatAndScale",
217+
operation_id=f"{prefix}getWebMercatorQuadTileWithFormatAndScale",
215218
**img_endpoint_params,
216219
)
217-
def tile_compat(
220+
def tile_compat( # type: ignore
218221
request: fastapi.Request,
219222
z: Annotated[
220223
int,
221224
Path(
222-
description="Identifier (Z) selecting one of the scales defined in the TileMatrixSet and representing the scaleDenominator the tile.",
225+
description="Identifier (Z) selecting one of the scales defined in the TileMatrixSet and representing the scaleDenominator the tile.", # noqa: F722,E501
223226
),
224227
],
225228
x: Annotated[
226229
int,
227230
Path(
228-
description="Column (X) index of the tile on the selected TileMatrix. It cannot exceed the MatrixHeight-1 for the selected TileMatrix.",
231+
description="Column (X) index of the tile on the selected TileMatrix. It cannot exceed the MatrixHeight-1 for the selected TileMatrix.", # noqa: F722,E501
229232
),
230233
],
231234
y: Annotated[
232235
int,
233236
Path(
234-
description="Row (Y) index of the tile on the selected TileMatrix. It cannot exceed the MatrixWidth-1 for the selected TileMatrix.",
237+
description="Row (Y) index of the tile on the selected TileMatrix. It cannot exceed the MatrixWidth-1 for the selected TileMatrix.", # noqa: F722,E501
235238
),
236239
],
237240
scale: Annotated[
238241
int,
239-
Field(gt=0, le=4, description="Tile size scale. 1=256x256, 2=512x512..."),
242+
Field(
243+
gt=0,
244+
le=4,
245+
description="Tile size scale. 1=256x256, 2=512x512...", # noqa: F722,E501
246+
),
240247
] = 1,
241248
format: Annotated[
242-
ImageType,
249+
Optional[ImageType],
243250
Field(
244-
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg)."
251+
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg)." # noqa: F722,E501
245252
),
246253
] = None,
247254
src_path=Depends(pc_tile_factory.path_dependency),
@@ -288,25 +295,29 @@ def tile_compat(
288295
response_model_exclude_none=True,
289296
operation_id=f"{pc_tile_factory.operation_prefix}getWebMercatorQuadTileJSON",
290297
)
291-
def tilejson_compat(
298+
def tilejson_compat( # type: ignore
292299
request: fastapi.Request,
293300
tile_format: Annotated[
294301
Optional[ImageType],
295302
Query(
296-
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg).",
303+
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg)." # noqa: F722,E501
297304
),
298305
] = None,
299306
tile_scale: Annotated[
300307
int,
301-
Query(gt=0, lt=4, description="Tile size scale. 1=256x256, 2=512x512..."),
308+
Query(
309+
gt=0,
310+
lt=4,
311+
description="Tile size scale. 1=256x256, 2=512x512...", # noqa: E501,F722
312+
),
302313
] = 1,
303314
minzoom: Annotated[
304315
Optional[int],
305-
Query(description="Overwrite default minzoom."),
316+
Query(description="Overwrite default minzoom."), # noqa: F722
306317
] = None,
307318
maxzoom: Annotated[
308319
Optional[int],
309-
Query(description="Overwrite default maxzoom."),
320+
Query(description="Overwrite default maxzoom."), # noqa: F722
310321
] = None,
311322
src_path=Depends(pc_tile_factory.path_dependency),
312323
reader_params=Depends(pc_tile_factory.reader_dependency),

pctiler/pctiler/endpoints/legend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def get_classmap_legend(
7070

7171
keys = list(classmap.keys()) # type: ignore
7272
trimmed_keys = keys[trim_start : len(keys) - trim_end]
73-
trimmed_map = {k: classmap[k] for k in trimmed_keys}
73+
trimmed_map = {k: classmap[k] for k in trimmed_keys} # type: ignore
7474

7575
return JSONResponse(content=trimmed_map)
7676

@@ -155,7 +155,7 @@ def make_colormap(name: str, trim_start: int, length: int) -> ListedColormap:
155155
if len(cm) > 256 or max(cm) >= 256:
156156
raise Exception("Cannot make a colormap for discrete colormap")
157157

158-
colors = make_lut(cm)
158+
colors = make_lut(cm) # type: ignore
159159

160160
colors = colors[trim_start : length + 1]
161161
# rescale to 0-1

pctiler/pctiler/endpoints/pg_mosaic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from psycopg_pool import ConnectionPool
77
from pydantic import Field
88
from titiler.core import dependencies
9-
from titiler.core.dependencies import ColorFormulaParams
109
from titiler.core.factory import img_endpoint_params
1110
from titiler.core.resources.enums import ImageType
1211
from titiler.pgstac.dependencies import SearchIdParams
@@ -87,7 +86,8 @@ def mosaic_info(
8786
legacy_mosaic_router = APIRouter()
8887

8988

90-
# Compat with titiler-pgstac<0.3.0, (`/tiles/{search_id}/...` was renamed `/{search_id}/tiles/...`)
89+
# Compat with titiler-pgstac<0.3.0,
90+
# (`/tiles/{search_id}/...` was renamed `/{search_id}/tiles/...`)
9191
@legacy_mosaic_router.get("/tiles/{search_id}/{z}/{x}/{y}", **img_endpoint_params)
9292
@legacy_mosaic_router.get(
9393
"/tiles/{search_id}/{z}/{x}/{y}.{format}", **img_endpoint_params
@@ -118,25 +118,25 @@ def tile_routes( # type: ignore
118118
z: Annotated[
119119
int,
120120
Path(
121-
description="Identifier (Z) selecting one of the scales defined in the TileMatrixSet and representing the scaleDenominator the tile.",
121+
description="Identifier (Z) selecting one of the scales defined in the TileMatrixSet and representing the scaleDenominator the tile.", # noqa: F722,E501
122122
),
123123
],
124124
x: Annotated[
125125
int,
126126
Path(
127-
description="Column (X) index of the tile on the selected TileMatrix. It cannot exceed the MatrixHeight-1 for the selected TileMatrix.",
127+
description="Column (X) index of the tile on the selected TileMatrix. It cannot exceed the MatrixHeight-1 for the selected TileMatrix.", # noqa: F722,E501
128128
),
129129
],
130130
y: Annotated[
131131
int,
132132
Path(
133-
description="Row (Y) index of the tile on the selected TileMatrix. It cannot exceed the MatrixWidth-1 for the selected TileMatrix.",
133+
description="Row (Y) index of the tile on the selected TileMatrix. It cannot exceed the MatrixWidth-1 for the selected TileMatrix.", # noqa: F722,E501
134134
),
135135
],
136136
search_id=Depends(pgstac_mosaic_factory.path_dependency),
137137
tileMatrixSetId: Annotated[ # type: ignore
138138
Literal[tuple(pgstac_mosaic_factory.supported_tms.list())],
139-
f"Identifier selecting one of the TileMatrixSetId supported (default: 'WebMercatorQuad')", # noqa: E501,F722
139+
"Identifier selecting one of the TileMatrixSetId supported (default: 'WebMercatorQuad')", # noqa: E501,F722
140140
] = "WebMercatorQuad",
141141
scale: Annotated[ # type: ignore
142142
Optional[Annotated[int, Field(gt=0, le=4)]],
@@ -145,7 +145,7 @@ def tile_routes( # type: ignore
145145
format: Annotated[
146146
Optional[ImageType],
147147
Field(
148-
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg)."
148+
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg)." # noqa: F722,E501
149149
),
150150
] = None,
151151
backend_params=Depends(pgstac_mosaic_factory.backend_dependency),

pctiler/pctiler/reader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ def _get_asset_info(self, asset: str) -> AssetInfo:
160160
info["media_type"] = media_type
161161

162162
if header_size := asset_info.get("file:header_size"):
163-
info["env"]["GDAL_INGESTED_BYTES_AT_OPEN"] = header_size
163+
info["env"].update( # type: ignore
164+
{"GDAL_INGESTED_BYTES_AT_OPEN": header_size}
165+
)
164166

165167
if bands := asset_info.get("raster:bands"):
166168
stats = [

0 commit comments

Comments
 (0)