From 4066c3b69564fb0dbffefa1c650e8c22c9bf12a3 Mon Sep 17 00:00:00 2001 From: devsjc <47188100+devsjc@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:50:02 +0000 Subject: [PATCH] fix(repo): Linting --- src/nwp_consumer/{cmd.tmp => cmd}/__init__.py | 0 src/nwp_consumer/{cmd.tmp => cmd}/main.py | 0 .../repositories/model_repositories/ceda_ftp.py | 2 +- .../repositories/model_repositories/mo_datahub.py | 10 +++++----- .../repositories/model_repositories/test_mo_datahub.py | 6 ++---- 5 files changed, 8 insertions(+), 10 deletions(-) rename src/nwp_consumer/{cmd.tmp => cmd}/__init__.py (100%) rename src/nwp_consumer/{cmd.tmp => cmd}/main.py (100%) diff --git a/src/nwp_consumer/cmd.tmp/__init__.py b/src/nwp_consumer/cmd/__init__.py similarity index 100% rename from src/nwp_consumer/cmd.tmp/__init__.py rename to src/nwp_consumer/cmd/__init__.py diff --git a/src/nwp_consumer/cmd.tmp/main.py b/src/nwp_consumer/cmd/main.py similarity index 100% rename from src/nwp_consumer/cmd.tmp/main.py rename to src/nwp_consumer/cmd/main.py diff --git a/src/nwp_consumer/internal/repositories/model_repositories/ceda_ftp.py b/src/nwp_consumer/internal/repositories/model_repositories/ceda_ftp.py index 76c10955..4f6d509a 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/ceda_ftp.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/ceda_ftp.py @@ -87,7 +87,7 @@ import numpy as np import xarray as xr from joblib import delayed -from returns.result import Failure, Result, ResultE, Success +from returns.result import Failure, ResultE, Success from nwp_consumer.internal import entities, ports diff --git a/src/nwp_consumer/internal/repositories/model_repositories/mo_datahub.py b/src/nwp_consumer/internal/repositories/model_repositories/mo_datahub.py index aff21d80..20e81255 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/mo_datahub.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/mo_datahub.py @@ -133,7 +133,7 @@ def fetch_init_data( return try: data = json.loads( - response.read().decode(response.info().get_param("charset") or "utf-8"), + response.read().decode(response.info().get_param("charset") or "utf-8"), # type: ignore ) except Exception as e: yield delayed(Failure( @@ -197,10 +197,10 @@ def _download(self, url: str) -> ResultE[pathlib.Path]: timeout=60, ) except Exception as e: - return Failure( + return Failure(OSError( "Unable to request file data from MetOffice DataHub at " f"'{url}': {e}", - ) + )) # Download the file log.debug("Downloading %s to %s", url, local_path) @@ -220,7 +220,7 @@ def _download(self, url: str) -> ResultE[pathlib.Path]: ), ) - return Success(local_path) + return Success(local_path) @staticmethod def _convert(path: pathlib.Path) -> ResultE[list[xr.DataArray]]: @@ -270,7 +270,7 @@ def _convert(path: pathlib.Path) -> ResultE[list[xr.DataArray]]: try: da: xr.DataArray = ( - ds.pipe(MetOfficeDatahubModelRepository._rename_or_drop_vars, ) + ds.pipe(MetOfficeDatahubModelRepository._rename_or_drop_vars ) .rename(name_dict={"time": "init_time"}) .expand_dims(dim="init_time") .expand_dims(dim="step") diff --git a/src/nwp_consumer/internal/repositories/model_repositories/test_mo_datahub.py b/src/nwp_consumer/internal/repositories/model_repositories/test_mo_datahub.py index 6ea85fe0..c3d992fb 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/test_mo_datahub.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/test_mo_datahub.py @@ -1,14 +1,12 @@ -import dataclasses import datetime as dt import os import unittest -from returns.pipeline import flow, is_successful -from returns.pointfree import bind +from returns.pipeline import is_successful -from nwp_consumer.internal import entities from .mo_datahub import MetOfficeDatahubModelRepository + class TestMetOfficeDatahubModelRepository(unittest.TestCase): """Test the business methods of the MetOfficeDatahubModelRepository class."""