Skip to content

Commit

Permalink
Add workaround for old python not supporting ISO 8601 datetimes
Browse files Browse the repository at this point in the history
This should be removed when we drop python 3.10 support.
  • Loading branch information
jfrost-mo committed Aug 23, 2024
1 parent 4a7fa9d commit b1d6ab6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/CSET/_workflow_utils/fetch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import os
import shutil
import sys
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timedelta
from typing import Literal
Expand Down Expand Up @@ -85,6 +86,10 @@ def get_file(self, file_path: str, output_dir: str) -> None:

def _get_needed_environment_variables() -> dict:
"""Load the needed variables from the environment."""
# Python 3.10 and older don't fully support ISO 8601 datetime formats.
# TODO: Remove once we drop python 3.10.
if sys.version_info.minor < 11:
datetime.fromisoformat = isodate.parse_datetime
variables = {
"raw_path": os.environ["DATA_PATH"],
"date_type": os.environ["DATE_TYPE"],
Expand Down

0 comments on commit b1d6ab6

Please sign in to comment.