diff --git a/.github/workflows/branch_ci.yml b/.github/workflows/branch_ci.yml index 12ce9c47..ba18063e 100644 --- a/.github/workflows/branch_ci.yml +++ b/.github/workflows/branch_ci.yml @@ -52,6 +52,7 @@ jobs: - name: Typecheck package run: uv run mypy . + # TODO: GitHub output when https://github.com/python/mypy/pull/17771 merged # Job to run unittests # * Produces a JUnit XML report that can be displayed in the GitHub UI diff --git a/src/nwp_consumer/internal/repositories/model_repositories/ecmwf_realtime.py b/src/nwp_consumer/internal/repositories/model_repositories/ecmwf_realtime.py index b64f234b..db8acfba 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/ecmwf_realtime.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/ecmwf_realtime.py @@ -320,7 +320,7 @@ def _wanted_file(filename: str, it: dt.datetime, max_step: int) -> bool: """ prefix: str = os.getenv("ECMWF_DISSEMINATION_REALTIME_FILE_PREFIX", "A2") pattern: str = r"^" + prefix + r"[DS](\d{8})(\d{8})\d$" - match: re.Match | None = re.search(pattern=pattern, string=filename) + match: re.Match[str] | None = re.search(pattern=pattern, string=filename) if match is None: return False if it.strftime("%m%d%H%M") != match.group(1): diff --git a/src/nwp_consumer/internal/repositories/model_repositories/test_ecmwf_realtime.py b/src/nwp_consumer/internal/repositories/model_repositories/test_ecmwf_realtime.py index b799a36d..65d18b74 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/test_ecmwf_realtime.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/test_ecmwf_realtime.py @@ -38,7 +38,11 @@ def test__download_and_convert(self) -> None: urls: list[str] = [ f"s3://{f}" for f in c._fs.ls(f"{c.bucket}/ecmwf") - if c._wanted_file(f.split("/")[-1], test_it, c.model()) + if c._wanted_file( + filename=f.split("/")[-1], + it=test_it, + max_step=max(c.model().expected_coordinates.step), + ) ] for url in urls: @@ -59,8 +63,6 @@ def test__download_and_convert(self) -> None: def test__wanted_file(self) -> None: """Test the _wanted_file method.""" - c: ECMWFRealTimeS3ModelRepository = ECMWFRealTimeS3ModelRepository() - @dataclasses.dataclass class TestCase: name: str @@ -94,8 +96,8 @@ class TestCase: for t in tests: with self.subTest(name=t.name): - result = c._wanted_file( + result = ECMWFRealTimeS3ModelRepository._wanted_file( filename=t.filename, it=test_it, - max_step=max(c.model().expected_coordinates.step)) + max_step=max(ECMWFRealTimeS3ModelRepository.model().expected_coordinates.step)) self.assertEqual(result, t.expected) diff --git a/src/nwp_consumer/internal/services/consumer_service.py b/src/nwp_consumer/internal/services/consumer_service.py index c8b73525..dd470848 100644 --- a/src/nwp_consumer/internal/services/consumer_service.py +++ b/src/nwp_consumer/internal/services/consumer_service.py @@ -92,7 +92,8 @@ def consume(self, it: dt.datetime | None = None) -> ResultE[pathlib.Path]: if isinstance(write_result, Failure): log.error( f"Error writing data for init time '{it:%Y-%m-%d %H:%M}' " - f"and model {self.mr.repository().name}: {write_result.failure()!s}", + f"and model {self.mr.repository().name}: " + f"{write_result.failure()!s}", ) failed_etls += 1 @@ -102,7 +103,8 @@ def consume(self, it: dt.datetime | None = None) -> ResultE[pathlib.Path]: if failed_etls > 0: monitor.join() return Failure(OSError( - f"Failed to write {failed_etls} regions for init time '{it:%Y-%m-%d %H:%M}'. " + f"Failed to write {failed_etls} regions " + f"for init time '{it:%Y-%m-%d %H:%M}'. " "See error logs for details.", ))