Skip to content

Commit

Permalink
Mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GratienDSX committed Dec 12, 2024
1 parent 231454f commit b6e73ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
23 changes: 11 additions & 12 deletions src/meteole/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import tempfile
from abc import abstractmethod
from pathlib import Path
from typing import Dict, List, Optional

import pandas as pd
import xarray as xr
Expand Down Expand Up @@ -59,7 +58,7 @@ def __init__(
self.precision = precision
self._validate_parameters()

self.folderpath: Optional[Path] = None
self.folderpath: Path | None = None
self.get_capabilities()

def get_capabilities(self) -> pd.DataFrame:
Expand Down Expand Up @@ -111,7 +110,7 @@ def _get_available_feature(grid_axis, feature_name):
features = [int(feature) for feature in features]
return features

def get_coverage_description(self, coverage_id: str) -> Dict:
def get_coverage_description(self, coverage_id: str) -> dict:
"""This endpoint returns the available axis (times, heights) to properly query coverage
TODO: other informations can be fetched from this endpoint, not yet implemented.
Expand All @@ -136,7 +135,7 @@ def get_coverage_description(self, coverage_id: str) -> Dict:

def get_coverages(
self,
coverage_ids: List[str],
coverage_ids: list[str],
lat: tuple = const.FRANCE_METRO_LATITUDES,
long: tuple = const.FRANCE_METRO_LONGITUDES,
) -> pd.DataFrame:
Expand All @@ -159,8 +158,8 @@ def get_coverages(
def _get_coverage_id(
self,
indicator: str,
run: Optional[str] = None,
interval: Optional[str] = None,
run: str | None = None,
interval: str | None = None,
) -> str:
"""
Get a coverage_id from `capabilities`.
Expand Down Expand Up @@ -234,9 +233,9 @@ def get_coverage(
indicator: str | None = None,
lat: tuple = const.FRANCE_METRO_LATITUDES,
long: tuple = const.FRANCE_METRO_LONGITUDES,
heights: List[int] | None = None,
pressures: List[int] | None = None,
forecast_horizons: List[int] | None = None,
heights: list[int] | None = None,
pressures: list[int] | None = None,
forecast_horizons: list[int] | None = None,
run: str | None = None,
interval: str | None = None,
coverage_id: str = "",
Expand Down Expand Up @@ -288,8 +287,8 @@ def get_coverage(
return pd.concat(df_list, axis=0).reset_index(drop=True)

def _raise_if_invalid_or_fetch_default(
self, param_name: str, inputs: List[int] | None, availables: List[int]
) -> List[int]:
self, param_name: str, inputs: list[int] | None, availables: list[int]
) -> list[int]:
"""
Checks if the elements in `inputs` are in `availables` and raises a ValueError if not.
If `inputs` is empty or None, uses the first element from `availables` as the default value.
Expand Down Expand Up @@ -345,7 +344,7 @@ def instant_indicators(self) -> str:
"""The list of instant indicators"""
pass

def _get_capabilities(self) -> Dict:
def _get_capabilities(self) -> dict:
"""The Capabilities of the AROME/ARPEGE service."""

url = f"{self.base_url}/{self.entry_point}/GetCapabilities"
Expand Down
4 changes: 1 addition & 3 deletions src/meteole/raster.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Functionnalities to deal with the raster data"""
from typing import Optional

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import rasterio
Expand All @@ -19,7 +17,7 @@ def plot_tiff_file(
filename,
data_type: str,
unit: str,
title: Optional[str] = None,
title: str | None = None,
):
"""
Plot a tiff file.
Expand Down
3 changes: 1 addition & 2 deletions src/meteole/vigilance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
from io import BytesIO
from typing import Tuple

import matplotlib.image as mpimg
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -89,7 +88,7 @@ def get_carte_vigilance(self) -> dict:

return req.json()

def get_phenomenon(self) -> Tuple[pd.DataFrame, pd.DataFrame]:
def get_phenomenon(self) -> tuple[pd.DataFrame, pd.DataFrame]:
"""
get risk prediction by phenomenon and by domain
Returns:
Expand Down

0 comments on commit b6e73ac

Please sign in to comment.