Skip to content

Commit

Permalink
Fix typing of restapi
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Mar 11, 2024
1 parent 23cd586 commit 301667b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ unfixable = ["ERA", "F401", "F841", "T20", "ERA001"]
"tests/*" = ["S101"]
"tests/provider/dwd/observation/test_available_datasets.py" = ["E402"]
"wetterdienst/__init__.py" = ["E402"]
"wetterdienst/ui/restapi.py" = ["B008"]
"wetterdienst/ui/restapi.py" = ["B008", "UP007"]

[tool.pytest.ini_options]
addopts = "-rsfEX -p pytester --strict-markers --verbosity=3 --webdriver=Firefox --headless"
Expand Down
116 changes: 58 additions & 58 deletions wetterdienst/ui/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import json
import logging
from typing import TYPE_CHECKING, Annotated, Any, Literal
from typing import TYPE_CHECKING, Annotated, Any, Literal, Union

from click_params import StringListParamType
from fastapi import FastAPI, HTTPException, Query
Expand Down Expand Up @@ -174,11 +174,11 @@ def health():

@app.get("/api/coverage")
def coverage(
provider: Annotated[str | None, Query()] = None,
network: Annotated[str | None, Query()] = None,
provider: Annotated[Union[str, None], Query()] = None,
network: Annotated[Union[str, None], Query()] = None,
debug: Annotated[bool, Query()] = False,
dataset: Annotated[str | None, Query()] = None,
resolution: Annotated[str | None, Query()] = None,
dataset: Annotated[Union[str, None], Query()] = None,
resolution: Annotated[Union[str, None], Query()] = None,
):
set_logging_level(debug)

Expand All @@ -201,21 +201,21 @@ def coverage(
# - _StationsDict for json
# - _StationsOgcFeatureCollection for geojson
# - str for csv
@app.get("/api/stations", response_model=_StationsDict | _StationsOgcFeatureCollection | str)
@app.get("/api/stations", response_model=Union[_StationsDict, _StationsOgcFeatureCollection, str])
def stations(
provider: Annotated[str | None, Query()] = None,
network: Annotated[str | None, Query()] = None,
parameter: Annotated[str | None, Query()] = None,
resolution: Annotated[str | None, Query()] = None,
period: Annotated[str | None, Query()] = None,
all_: Annotated[bool | None, Query(alias="all")] = None,
station: Annotated[str | None, Query()] = None,
name: Annotated[str | None, Query()] = None,
coordinates: Annotated[str | None, Query()] = None,
rank: Annotated[int | None, Query()] = None,
distance: Annotated[float | None, Query()] = None,
bbox: Annotated[str | None, Query()] = None,
sql: Annotated[str | None, Query()] = None,
provider: Annotated[Union[str, None], Query()] = None,
network: Annotated[Union[str, None], Query()] = None,
parameter: Annotated[Union[str, None], Query()] = None,
resolution: Annotated[Union[str, None], Query()] = None,
period: Annotated[Union[str, None], Query()] = None,
all_: Annotated[Union[bool, None], Query(alias="all")] = None,
station: Annotated[Union[str, None], Query()] = None,
name: Annotated[Union[str, None], Query()] = None,
coordinates: Annotated[Union[str, None], Query()] = None,
rank: Annotated[Union[int, None], Query()] = None,
distance: Annotated[Union[float, None], Query()] = None,
bbox: Annotated[Union[str, None], Query()] = None,
sql: Annotated[Union[str, None], Query()] = None,
fmt: Annotated[str, Query(alias="format")] = "json",
pretty: Annotated[bool, Query()] = None,
debug: Annotated[bool, Query()] = None,
Expand Down Expand Up @@ -301,25 +301,25 @@ def stations(
# - _ValuesDict for json
# - _ValuesOgcFeatureCollection for geojson
# - str for csv
@app.get("/api/values", response_model=_ValuesDict | _ValuesOgcFeatureCollection | str)
@app.get("/api/values", response_model=Union[_ValuesDict, _ValuesOgcFeatureCollection, str])
def values(
provider: Annotated[str | None, Query()] = None,
network: Annotated[str | None, Query()] = None,
parameter: Annotated[str | None, Query()] = None,
resolution: Annotated[str | None, Query()] = None,
period: Annotated[str | None, Query()] = None,
provider: Annotated[Union[str, None], Query()] = None,
network: Annotated[Union[str, None], Query()] = None,
parameter: Annotated[Union[str, None], Query()] = None,
resolution: Annotated[Union[str, None], Query()] = None,
period: Annotated[Union[str, None], Query()] = None,
lead_time: Annotated[Literal["short", "long"] | None, Query()] = None,
date: Annotated[str | None, Query()] = None,
issue: Annotated[str | None, Query()] = None,
all_: Annotated[bool | None, Query(alias="all")] = None,
station: Annotated[str | None, Query()] = None,
name: Annotated[str | None, Query()] = None,
coordinates: Annotated[str | None, Query()] = None,
rank: Annotated[int | None, Query()] = None,
distance: Annotated[float | None, Query()] = None,
bbox: Annotated[str | None, Query()] = None,
sql: Annotated[str | None, Query()] = None,
sql_values: Annotated[str | None, Query(alias="sql-values")] = None,
date: Annotated[Union[str, None], Query()] = None,
issue: Annotated[Union[str, None], Query()] = None,
all_: Annotated[Union[bool, None], Query(alias="all")] = None,
station: Annotated[Union[str, None], Query()] = None,
name: Annotated[Union[str, None], Query()] = None,
coordinates: Annotated[Union[str, None], Query()] = None,
rank: Annotated[Union[int, None], Query()] = None,
distance: Annotated[Union[float, None], Query()] = None,
bbox: Annotated[Union[str, None], Query()] = None,
sql: Annotated[Union[str, None], Query()] = None,
sql_values: Annotated[Union[str, None], Query(alias="sql-values")] = None,
humanize: Annotated[bool, Query()] = True,
shape: Annotated[str, Query()] = "long",
si_units: Annotated[bool, Query(alias="si-units")] = True,
Expand Down Expand Up @@ -410,20 +410,20 @@ def values(
# - str for csv
@app.get(
"/api/interpolate",
response_model=_InterpolatedValuesDict | _InterpolatedValuesOgcFeatureCollection | str,
response_model=Union[_InterpolatedValuesDict, _InterpolatedValuesOgcFeatureCollection, str],
)
def interpolate(
provider: Annotated[str | None, Query()] = None,
network: Annotated[str | None, Query()] = None,
parameter: Annotated[str | None, Query()] = None,
resolution: Annotated[str | None, Query()] = None,
period: Annotated[str | None, Query()] = None,
provider: Annotated[Union[str, None], Query()] = None,
network: Annotated[Union[str, None], Query()] = None,
parameter: Annotated[Union[str, None], Query()] = None,
resolution: Annotated[Union[str, None], Query()] = None,
period: Annotated[Union[str, None], Query()] = None,
lead_time: Annotated[Literal["short", "long"] | None, Query()] = None,
date: Annotated[str | None, Query()] = None,
issue: Annotated[str | None, Query()] = None,
station: Annotated[str | None, Query()] = None,
coordinates: Annotated[str | None, Query()] = None,
sql_values: Annotated[str | None, Query(alias="sql-values")] = None,
date: Annotated[Union[str, None], Query()] = None,
issue: Annotated[Union[str, None], Query()] = None,
station: Annotated[Union[str, None], Query()] = None,
coordinates: Annotated[Union[str, None], Query()] = None,
sql_values: Annotated[Union[str, None], Query(alias="sql-values")] = None,
humanize: Annotated[bool, Query()] = True,
si_units: Annotated[bool, Query(alias="si-units")] = True,
use_nearby_station_distance: Annotated[float, Query()] = 1.0,
Expand Down Expand Up @@ -499,19 +499,19 @@ def interpolate(
# - _SummarizedValuesDict for json
# - _SummarizedValuesOgcFeatureCollection for geojson
# - str for csv
@app.get("/api/summarize", response_model=_SummarizedValuesDict | _SummarizedValuesOgcFeatureCollection | str)
@app.get("/api/summarize", response_model=Union[_SummarizedValuesDict, _SummarizedValuesOgcFeatureCollection, str])
def summarize(
provider: Annotated[str | None, Query()] = None,
network: Annotated[str | None, Query()] = None,
parameter: Annotated[str | None, Query()] = None,
resolution: Annotated[str | None, Query()] = None,
period: Annotated[str | None, Query()] = None,
provider: Annotated[Union[str, None], Query()] = None,
network: Annotated[Union[str, None], Query()] = None,
parameter: Annotated[Union[str, None], Query()] = None,
resolution: Annotated[Union[str, None], Query()] = None,
period: Annotated[Union[str, None], Query()] = None,
lead_time: Annotated[Literal["short", "long"] | None, Query()] = None,
date: Annotated[str | None, Query()] = None,
issue: Annotated[str | None, Query()] = "latest",
station: Annotated[str | None, Query()] = None,
coordinates: Annotated[str | None, Query()] = None,
sql_values: Annotated[str | None, Query(alias="sql-values")] = None,
date: Annotated[Union[str, None], Query()] = None,
issue: Annotated[Union[str, None], Query()] = "latest",
station: Annotated[Union[str, None], Query()] = None,
coordinates: Annotated[Union[str, None], Query()] = None,
sql_values: Annotated[Union[str, None], Query(alias="sql-values")] = None,
humanize: Annotated[bool, Query()] = True,
si_units: Annotated[bool, Query(alias="si-units")] = True,
fmt: Annotated[Literal["json", "geojson", "csv"], Query(alias="format")] = "json",
Expand Down

0 comments on commit 301667b

Please sign in to comment.