Skip to content

Commit

Permalink
🎨 Update type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
arafune committed Feb 16, 2024
1 parent 72189aa commit cf92e56
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/arpes/endstations/plugin/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
if TYPE_CHECKING:
from pathlib import Path

import xarray as xr
from _typeshed import Incomplete

from arpes.endstations import SCANDESC
Expand Down Expand Up @@ -79,8 +80,8 @@ def determine_associated_loader(
endstation_cls = resolve_endstation(retry=False, location=location)
if endstation_cls.is_file_accepted(file):
return endstation_cls
except Exception as err:
logger.info(f"Exception occurs. {err=}, {type(err)=}")
except BaseException:
logger.exception("Exception occurs.")

msg = f"PyARPES failed to find a plugin acceptable for {file}."
raise ValueError(msg)
Expand All @@ -90,18 +91,15 @@ def load(
scan_desc: SCANDESC | None = None,
file: str | Path = "",
**kwargs: Incomplete,
):
) -> xr.Dataset:
"""Delegates to a dynamically chosen plugin for loading."""
if scan_desc is None:
scan_desc = {}
if not file:
assert scan_desc is not None
file = scan_desc["file"]
assert isinstance(file, str)
associated_loader = FallbackEndstation.determine_associated_loader(
file,
scan_desc,
)
associated_loader = FallbackEndstation.determine_associated_loader(file)
try:
file_number = int(file)
file = associated_loader.find_first_file(file_number)
Expand All @@ -120,6 +118,6 @@ def find_first_file(cls: type[FallbackEndstation], file_number: int) -> Path:
which loading pluging should be used. Then, we delegate to that class to
find the first associated file.
"""
associated_loader = cls.determine_associated_loader(file_number)
associated_loader = cls.determine_associated_loader(str(file_number))
warnings.warn(AUTOLOAD_WARNING.format(associated_loader), stacklevel=2)
return associated_loader.find_first_file(file_number)

0 comments on commit cf92e56

Please sign in to comment.