Skip to content

Commit b3aff23

Browse files
Merge pull request #21 from developmentseed/updateRequirements
update requirements
2 parents 5fcb109 + 48b29bc commit b3aff23

File tree

6 files changed

+106
-29
lines changed

6 files changed

+106
-29
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
repos:
2+
- repo: https://github.com/abravalheri/validate-pyproject
3+
rev: v0.12.1
4+
hooks:
5+
- id: validate-pyproject
6+
27
- repo: https://github.com/psf/black
3-
rev: 22.3.0
8+
rev: 22.12.0
49
hooks:
510
- id: black
611
language_version: python
@@ -11,26 +16,18 @@ repos:
1116
- id: isort
1217
language_version: python
1318

14-
- repo: https://github.com/PyCQA/flake8
15-
rev: 3.8.3
19+
- repo: https://github.com/charliermarsh/ruff-pre-commit
20+
rev: v0.0.238
1621
hooks:
17-
- id: flake8
18-
language_version: python
19-
20-
- repo: https://github.com/PyCQA/pydocstyle
21-
rev: 6.1.1
22-
hooks:
23-
- id: pydocstyle
24-
language_version: python
25-
additional_dependencies:
26-
- toml
22+
- id: ruff
23+
args: ["--fix"]
2724

2825
- repo: https://github.com/pre-commit/mirrors-mypy
2926
rev: v0.991
3027
hooks:
3128
- id: mypy
3229
language_version: python
30+
# No reason to run if only tests have changed. They intentionally break typing.
31+
exclude: tests/.*
3332
additional_dependencies:
3433
- types-attrs
35-
36-

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11

2+
## 0.11.0 (2023-10-18)
3+
4+
* update requirements
5+
- `rio-tiler>=6.0,<7.0`
6+
- `fastapi>=0.100.0`
7+
28
## 0.10.0 (2023-06-02)
39

410
* update `rio-tiler` requirement

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Development - Contributing
2+
3+
Issues and pull requests are more than welcome: https://github.com/developmentseed/tilebench/issues
4+
5+
**dev install**
6+
7+
```bash
8+
git clone https://github.com/developmentseed/tilebench.git
9+
cd tilebench
10+
python -m pip install -e ".[dev,test]"
11+
```
12+
13+
You can then run the tests with the following command:
14+
15+
```sh
16+
python -m pytest --cov tilebench --cov-report term-missing -s -vv
17+
```
18+
19+
This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.
20+
21+
```bash
22+
$ pre-commit install
23+
```

pyproject.toml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "tilebench"
33
description = "Inspect HEAD/LIST/GET requests withing Rasterio"
44
requires-python = ">=3.8"
5-
license = "MIT"
5+
license = {file = "LICENSE"}
66
authors = [
77
{name = "Vincent Sarago", email = "[email protected]"},
88
]
@@ -20,13 +20,11 @@ classifiers = [
2020
]
2121
dynamic = ["version", "readme"]
2222
dependencies = [
23-
"aiofiles",
24-
"fastapi>=0.73",
23+
"fastapi>=0.100.0",
2524
"jinja2>=3.0,<4.0.0",
26-
"geojson-pydantic",
2725
"loguru",
2826
"rasterio>=1.3.0",
29-
"rio-tiler>=4.0,<6.0",
27+
"rio-tiler>=6.0,<7.0",
3028
"wurlitzer",
3129
"uvicorn[standard]",
3230
]
@@ -92,8 +90,19 @@ known_third_party = ["rasterio", "rio_tiler", "morecantile", "geojson_pydantic",
9290
default_section = "THIRDPARTY"
9391

9492
[tool.mypy]
95-
no_strict_optional = "True"
93+
no_strict_optional = true
9694

97-
[tool.pydocstyle]
98-
select = "D1"
99-
match = "(?!test).*.py"
95+
[tool.ruff]
96+
select = [
97+
"D1", # pydocstyle errors
98+
"E", # pycodestyle errors
99+
"W", # pycodestyle warnings
100+
"F", # flake8
101+
"C", # flake8-comprehensions
102+
"B", # flake8-bugbear
103+
]
104+
ignore = [
105+
"E501", # line too long, handled by black
106+
"B008", # do not perform function calls in argument defaults
107+
"B905", # ignore zip() without an explicit strict= parameter, only support with python >3.10
108+
]

tilebench/scripts/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def get_zooms(input, reader):
135135
Reader = reader or COGReader
136136

137137
with Reader(input, tms=tms) as cog:
138-
click.echo(json.dumps(dict(minzoom=cog.minzoom, maxzoom=cog.maxzoom)))
138+
click.echo(json.dumps({"minzoom": cog.minzoom, "maxzoom": cog.maxzoom}))
139139

140140

141141
@cli.command()

tilebench/viz.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy
1010
import rasterio
1111
import uvicorn
12-
from fastapi import APIRouter, FastAPI, Query
12+
from fastapi import APIRouter, FastAPI, Path, Query
1313
from fastapi.staticfiles import StaticFiles
1414
from rasterio import windows
1515
from rasterio._path import _parse_path as parse_path
@@ -20,6 +20,7 @@
2020
from starlette.requests import Request
2121
from starlette.responses import HTMLResponse, Response
2222
from starlette.templating import Jinja2Templates
23+
from typing_extensions import Annotated
2324

2425
from tilebench import Timer
2526
from tilebench import profile as profiler
@@ -149,10 +150,31 @@ def register_routes(self):
149150
"""Register routes to the FastAPI app."""
150151

151152
@self.router.get(r"/tiles/{z}/{x}/{y}.png", response_class=PNGResponse)
152-
def image(response: Response, z: int, x: int, y: int):
153+
def image(
154+
response: Response,
155+
z: Annotated[
156+
int,
157+
Path(
158+
description="Identifier (Z) selecting one of the scales defined in the TileMatrixSet and representing the scaleDenominator the tile.",
159+
),
160+
],
161+
x: Annotated[
162+
int,
163+
Path(
164+
description="Column (X) index of the tile on the selected TileMatrix. It cannot exceed the MatrixHeight-1 for the selected TileMatrix.",
165+
),
166+
],
167+
y: Annotated[
168+
int,
169+
Path(
170+
description="Row (Y) index of the tile on the selected TileMatrix. It cannot exceed the MatrixWidth-1 for the selected TileMatrix.",
171+
),
172+
],
173+
):
153174
"""Handle /image requests."""
154175
with self.reader(self.src_path) as src_dst:
155176
img = src_dst.tile(x, y, z)
177+
156178
return PNGResponse(
157179
render(
158180
numpy.zeros((1, 256, 256), dtype="uint8"),
@@ -163,7 +185,27 @@ def image(response: Response, z: int, x: int, y: int):
163185
)
164186

165187
@self.router.get(r"/tiles/{z}/{x}/{y}")
166-
def tile(response: Response, z: int, x: int, y: int):
188+
def tile(
189+
response: Response,
190+
z: Annotated[
191+
int,
192+
Path(
193+
description="Identifier (Z) selecting one of the scales defined in the TileMatrixSet and representing the scaleDenominator the tile.",
194+
),
195+
],
196+
x: Annotated[
197+
int,
198+
Path(
199+
description="Column (X) index of the tile on the selected TileMatrix. It cannot exceed the MatrixHeight-1 for the selected TileMatrix.",
200+
),
201+
],
202+
y: Annotated[
203+
int,
204+
Path(
205+
description="Row (Y) index of the tile on the selected TileMatrix. It cannot exceed the MatrixWidth-1 for the selected TileMatrix.",
206+
),
207+
],
208+
):
167209
"""Handle /tiles requests."""
168210

169211
@profiler(
@@ -272,7 +314,7 @@ def info():
272314
response_model_exclude_none=True,
273315
response_class=GeoJSONResponse,
274316
)
275-
def grid(ovr_level: int = Query(...)):
317+
def grid(ovr_level: Annotated[int, Query(description="Overview Level")]):
276318
"""return geojson."""
277319
options = {"OVERVIEW_LEVEL": ovr_level - 1} if ovr_level else {}
278320
with rasterio.open(self.src_path, **options) as src_dst:

0 commit comments

Comments
 (0)