Skip to content

Commit

Permalink
bug: fix typing.Unpack in py3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
alastairtree committed Jul 28, 2024
1 parent 0243b41 commit 95da0ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/imap_mag/SDC.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path

import pandas as pd
from typing_extensions import Unpack

from .sdcApiClient import ISDCApiClient
from .time import Time
Expand Down Expand Up @@ -46,7 +47,7 @@ def __init__(self, data_access: ISDCApiClient) -> None:

self.__data_access = data_access

def QueryAndDownload(self, **options: typing.Unpack[SDCOptions]) -> list[Path]:
def QueryAndDownload(self, **options: Unpack[SDCOptions]) -> list[Path]:
"""Retrieve SDC data."""

downloaded = []
Expand Down Expand Up @@ -114,7 +115,7 @@ def __check_download_needed(
self,
details: dict,
date: datetime,
**options: typing.Unpack[SDCOptions],
**options: Unpack[SDCOptions],
) -> bool:
"""Check if files need to be downloaded."""

Expand Down
17 changes: 9 additions & 8 deletions src/imap_mag/sdcApiClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datetime import datetime

import imap_data_access
from typing_extensions import Unpack


class FileOptions(typing.TypedDict):
Expand Down Expand Up @@ -41,7 +42,7 @@ class ISDCApiClient(abc.ABC):

@staticmethod
@abc.abstractmethod
def get_file_path(**options: typing.Unpack[FileOptions]) -> tuple[str, str]:
def get_file_path(**options: Unpack[FileOptions]) -> tuple[str, str]:
"""Get file path for data from imap-data-access."""
pass

Expand All @@ -52,19 +53,19 @@ def upload(self, file_name: str) -> None:

@abc.abstractmethod
def unique_version(
self, **options: typing.Unpack[VersionOptions]
self, **options: Unpack[VersionOptions]
) -> tuple[str, str | None]:
"""Determine a unique version for the data by querying imap_data_access."""
pass

@abc.abstractmethod
def query(self, **options: typing.Unpack[QueryOptions]) -> list[dict[str, str]]:
def query(self, **options: Unpack[QueryOptions]) -> list[dict[str, str]]:
"""Download data from imap-data-access."""
pass

@abc.abstractmethod
def get_filename(
self, **options: typing.Unpack[FileOptions]
self, **options: Unpack[FileOptions]
) -> list[dict[str, str]] | None:
"""Wait for file to be available in imap-data-access."""
pass
Expand All @@ -82,7 +83,7 @@ def __init__(self, data_dir: str) -> None:
imap_data_access.config["DATA_DIR"] = pathlib.Path(data_dir)

@staticmethod
def get_file_path(**options: typing.Unpack[FileOptions]) -> tuple[str, str]:
def get_file_path(**options: Unpack[FileOptions]) -> tuple[str, str]:
"""Get file path for data from imap-data-access."""

science_file = imap_data_access.ScienceFilePath.generate_from_inputs(
Expand All @@ -106,7 +107,7 @@ def upload(self, file_name: str) -> None:
logging.warn(f"Upload failed: {e}")

def unique_version(
self, **options: typing.Unpack[VersionOptions]
self, **options: Unpack[VersionOptions]
) -> tuple[str, str | None]:
"""Determine a unique version for the data by querying imap_data_access."""

Expand All @@ -132,7 +133,7 @@ def unique_version(

return (unique_version, max_version)

def query(self, **options: typing.Unpack[QueryOptions]) -> list[dict[str, str]]:
def query(self, **options: Unpack[QueryOptions]) -> list[dict[str, str]]:
"""Download data from imap-data-access."""

return imap_data_access.query(
Expand All @@ -152,7 +153,7 @@ def query(self, **options: typing.Unpack[QueryOptions]) -> list[dict[str, str]]:
)

def get_filename(
self, **options: typing.Unpack[FileOptions]
self, **options: Unpack[FileOptions]
) -> list[dict[str, str]] | None:
science_file = imap_data_access.ScienceFilePath.generate_from_inputs(
instrument="mag",
Expand Down

0 comments on commit 95da0ed

Please sign in to comment.