From 06126e1afce5683c94db0f1e54b0d00c7f6ffddf Mon Sep 17 00:00:00 2001 From: Orion Eiger Date: Tue, 15 Oct 2024 17:00:22 -0700 Subject: [PATCH] Amend tests to cooperate with new mypy (thanks @timj) --- python/lsst/pipe/base/tests/mocks/_storage_class.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python/lsst/pipe/base/tests/mocks/_storage_class.py b/python/lsst/pipe/base/tests/mocks/_storage_class.py index 2ac6b2989..b65893361 100644 --- a/python/lsst/pipe/base/tests/mocks/_storage_class.py +++ b/python/lsst/pipe/base/tests/mocks/_storage_class.py @@ -628,13 +628,17 @@ def new_get_formatter_class_with_match( try: return original_get_formatter_class_with_match(self, entity) except KeyError: - lookup_keys = (LookupKey(name=entity),) if isinstance(entity, str) else entity._lookupNames() + lookup_keys: tuple[LookupKey, ...] = ( + (LookupKey(name=entity),) if isinstance(entity, str) else entity._lookupNames() + ) for key in lookup_keys: # This matches mock dataset type names before mock storage # classes, and it would even match some regular dataset types # that are automatic connections (logs, configs, metadata) of # mocked tasks. The latter would be a problem, except that # those should have already matched in the try block above. + if key.name is None: + continue if is_mock_name(key.name): return (key, JsonFormatter, {}) raise @@ -651,8 +655,12 @@ def new_get_formatter_with_match( try: return original_get_formatter_with_match(self, entity, *args, **kwargs) except KeyError: - lookup_keys = (LookupKey(name=entity),) if isinstance(entity, str) else entity._lookupNames() + lookup_keys: tuple[LookupKey, ...] = ( + (LookupKey(name=entity),) if isinstance(entity, str) else entity._lookupNames() + ) for key in lookup_keys: + if key.name is None: + continue if is_mock_name(key.name): return (key, JsonFormatter(*args, **kwargs)) raise