diff --git a/.github/workflows/static-anaysis.yml b/.github/workflows/static-anaysis.yml index 2c31cf49..0f7e9399 100644 --- a/.github/workflows/static-anaysis.yml +++ b/.github/workflows/static-anaysis.yml @@ -4,7 +4,7 @@ on: push jobs: call-ruff-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.13.2 cfn-lint: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 1093355d..d3ed7cf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.5.10] +### Changed +- Update `ruff` configuration to our latest standards. + ## [0.5.9] ### Changed - Improved deduplication performance by searching HyP3's dynamodb directly for `PENDING` and `RUNNING` jobs, instead of using the `hyp3_sdk`. diff --git a/its_live_monitoring/src/main.py b/its_live_monitoring/src/main.py index 72b8f8ed..fe8d1407 100644 --- a/its_live_monitoring/src/main.py +++ b/its_live_monitoring/src/main.py @@ -5,7 +5,7 @@ import logging import os import sys -from datetime import datetime, timezone +from datetime import UTC, datetime import boto3 import geopandas as gpd @@ -128,7 +128,7 @@ def format_time(time: datetime) -> str: """ if time.tzinfo is None: raise ValueError(f'missing tzinfo for datetime {time}') - utc_time = time.astimezone(timezone.utc) + utc_time = time.astimezone(UTC) return utc_time.isoformat(timespec='seconds') diff --git a/ruff.toml b/pyproject.toml similarity index 63% rename from ruff.toml rename to pyproject.toml index 1c5415e4..646c7be4 100644 --- a/ruff.toml +++ b/pyproject.toml @@ -1,11 +1,17 @@ +[project] +requires-python = "==3.12" + +[tool.ruff] line-length = 120 -src = ["its_live_monitoring/src", "status-messages/src", "tests"] +# The directories to consider when resolving first- vs. third-party imports. +# See: https://docs.astral.sh/ruff/settings/#src +src = ["**/src", "tests"] -[format] +[tool.ruff.format] indent-style = "space" quote-style = "single" -[lint] +[tool.ruff.lint] extend-select = [ "I", # isort: https://docs.astral.sh/ruff/rules/#isort-i "UP", # pyupgrade: https://docs.astral.sh/ruff/rules/#pyupgrade-up @@ -14,12 +20,12 @@ extend-select = [ "PTH", # use-pathlib-pth: https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth ] -[lint.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" -[lint.isort] +[tool.ruff.lint.isort] case-sensitive = true lines-after-imports = 2 -[lint.extend-per-file-ignores] +[tool.ruff.lint.extend-per-file-ignores] "tests/*" = ["D100", "D103", "ANN"] diff --git a/status-messages/src/status_messages.py b/status-messages/src/status_messages.py index 72430ede..fe1df3da 100644 --- a/status-messages/src/status_messages.py +++ b/status-messages/src/status_messages.py @@ -4,7 +4,7 @@ import logging import os import sys -from datetime import datetime, timezone +from datetime import UTC, datetime from pathlib import Path import boto3 @@ -59,7 +59,7 @@ def lambda_handler(event: dict, context: dict) -> None: mattermost_message = ( f'{status_emoji} Dead Letter Queue Count for `{queue_name}` has ' - f'{dead_letter_queue_count} entries on {datetime.now(tz=timezone.utc).isoformat()}' + f'{dead_letter_queue_count} entries on {datetime.now(tz=UTC).isoformat()}' ) log.info(f'Posting: "{mattermost_message}" to {MATTERMOST_CHANNEL_ID}') diff --git a/tests/its_live_monitoring/test_landsat.py b/tests/its_live_monitoring/test_landsat.py index e769cbf6..edda8b57 100644 --- a/tests/its_live_monitoring/test_landsat.py +++ b/tests/its_live_monitoring/test_landsat.py @@ -1,5 +1,5 @@ from copy import deepcopy -from datetime import datetime, timezone +from datetime import UTC, datetime from unittest.mock import patch import landsat @@ -123,9 +123,9 @@ def test_get_landsat_pairs_for_reference_scene(mock_landsat_get_item, pystac_ite 'LC09_L1TP_138041_20240104_20240104_02_T1', ] sec_date_times = [ - datetime(2024, 1, 20, 4, 30, 3, 658618, tzinfo=timezone.utc), - datetime(2024, 1, 12, 4, 29, 55, tzinfo=timezone.utc), - datetime(2024, 1, 4, 4, 30, 3, 184014, tzinfo=timezone.utc), + datetime(2024, 1, 20, 4, 30, 3, 658618, tzinfo=UTC), + datetime(2024, 1, 12, 4, 29, 55, tzinfo=UTC), + datetime(2024, 1, 4, 4, 30, 3, 184014, tzinfo=UTC), ] sec_items = [] for scene, date_time in zip(sec_scenes, sec_date_times): diff --git a/tests/its_live_monitoring/test_sentinel2.py b/tests/its_live_monitoring/test_sentinel2.py index 3afd67a5..923f91f9 100644 --- a/tests/its_live_monitoring/test_sentinel2.py +++ b/tests/its_live_monitoring/test_sentinel2.py @@ -1,5 +1,5 @@ from copy import deepcopy -from datetime import datetime, timezone +from datetime import UTC, datetime from unittest.mock import patch import pystac @@ -192,9 +192,9 @@ def test_get_sentinel2_pairs_for_reference_scene( 'S2B_22TCR_20210528_0_L1C', ] sec_date_times = [ - datetime(2024, 5, 28, 0, 0, 0, 0, tzinfo=timezone.utc), - datetime(2023, 5, 28, 0, 0, 0, tzinfo=timezone.utc), - datetime(2021, 5, 28, 0, 0, 0, 0, tzinfo=timezone.utc), + datetime(2024, 5, 28, 0, 0, 0, 0, tzinfo=UTC), + datetime(2023, 5, 28, 0, 0, 0, tzinfo=UTC), + datetime(2021, 5, 28, 0, 0, 0, 0, tzinfo=UTC), ] sec_items = [] for scene, date_time in zip(sec_scenes, sec_date_times):