Skip to content

Commit

Permalink
Allow for a storage class converter to be a builtin type
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jul 24, 2024
1 parent 7f73058 commit 64db716
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions python/lsst/daf/butler/_storage_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,22 @@ def _get_converters_by_type(self) -> Mapping[type, Callable[[Any], Any]]:
del self._converters[candidate_type_str]
continue

try:
converter = doImportType(converter_str)
except ImportError as e:
log.warning(
"Unable to import conversion function %s associated with storage class %s "
"required to convert type %s (%s)",
converter_str,
self.name,
candidate_type_str,
e,
)
del self._converters[candidate_type_str]
continue
if hasattr(builtins, converter_str):
converter = getattr(builtins, converter_str)
else:
try:
converter = doImportType(converter_str)
except ImportError as e:
log.warning(
"Unable to import conversion function %s associated with storage class %s "
"required to convert type %s (%s)",
converter_str,
self.name,
candidate_type_str,
e,
)
del self._converters[candidate_type_str]
continue
if not callable(converter):
# doImportType is annotated to return a Type but in actual
# fact it can return Any except ModuleType because package
Expand Down

0 comments on commit 64db716

Please sign in to comment.