Skip to content

Commit

Permalink
Amend tests to cooperate with new mypy (thanks @timj)
Browse files Browse the repository at this point in the history
  • Loading branch information
eigerx committed Oct 16, 2024
1 parent 08bf168 commit 06126e1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/lsst/pipe/base/tests/mocks/_storage_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...] = (

Check warning on line 631 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L631

Added line #L631 was not covered by tests
(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

Check warning on line 641 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L641

Added line #L641 was not covered by tests
if is_mock_name(key.name):
return (key, JsonFormatter, {})
raise
Expand All @@ -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

Check warning on line 663 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L663

Added line #L663 was not covered by tests
if is_mock_name(key.name):
return (key, JsonFormatter(*args, **kwargs))
raise
Expand Down

0 comments on commit 06126e1

Please sign in to comment.