From ce167433eb0ab06bfe317757540f00906fbadb1b Mon Sep 17 00:00:00 2001 From: Max Drexler <mndrexler@wisc.edu> Date: Fri, 19 Jul 2024 17:12:47 +0000 Subject: [PATCH] mypy configuration --- grib_processor/__main__.py | 2 +- grib_processor/grib.py | 11 +++++++---- pyproject.toml | 7 +++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/grib_processor/__main__.py b/grib_processor/__main__.py index 117c779..87e7e74 100644 --- a/grib_processor/__main__.py +++ b/grib_processor/__main__.py @@ -11,4 +11,4 @@ from grib_processor.main import main if __name__ == "__main__": - sys.exit(main()) + sys.exit(main()) # type: ignore[func-returns-value] diff --git a/grib_processor/grib.py b/grib_processor/grib.py index 7abd235..7d848e1 100644 --- a/grib_processor/grib.py +++ b/grib_processor/grib.py @@ -15,7 +15,7 @@ from typing import Generator import grib2io from ssec_amqp import utils as amqp_utils -from typing_extensions import Literal, TypedDict +from typing_extensions import Literal, TypedDict, TypeAlias from grib_processor import data @@ -25,6 +25,9 @@ if sys.version_info < (3, 9): else: import importlib.resources as resources +# Custom types +IsoStr: TypeAlias = str + # Contains a serializable mapping of first_lat, first_lon, rows, cols, # and generating_process_ids to xcd model names and ids. # @@ -55,8 +58,8 @@ class GribMetadata(TypedDict): last_lon: float | None forecast_hour: int run_hour: int - model_time: datetime - start_time: datetime + model_time: IsoStr + start_time: IsoStr projection: str center_id: int center_desc: str @@ -82,7 +85,7 @@ class GribPayload(GribMetadata): the file and server itself. """ - __payload_gen_time__: datetime + __payload_gen_time__: IsoStr __injector_script__: str path: str directory: str diff --git a/pyproject.toml b/pyproject.toml index da5a069..822ff59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,3 +35,10 @@ packages = ["grib_processor"] [tool.setuptools.dynamic] version = {attr = "grib_processor.__version__"} + + +[tool.mypy] +python_version = "3.8" +disable_error_code = [ + "import-untyped", +] -- GitLab