Skip to content

Commit

Permalink
Merge pull request #225 from ASFHyP3/ruff
Browse files Browse the repository at this point in the history
Update ruff config
  • Loading branch information
jtherrmann authored Dec 18, 2024
2 parents 2afb7c7 + d6555d0 commit 17c8c50
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static-anaysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions its_live_monitoring/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')


Expand Down
18 changes: 12 additions & 6 deletions ruff.toml → pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
4 changes: 2 additions & 2 deletions status-messages/src/status_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}')
Expand Down
8 changes: 4 additions & 4 deletions tests/its_live_monitoring/test_landsat.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions tests/its_live_monitoring/test_sentinel2.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 17c8c50

Please sign in to comment.