Storage is a Protocol promising the method: account_list() We are calling the method to test (data_source.account_list) passing the mock. But before, we masquerade the mock (cast) to pretend it is compliant to the Storage protocol (which it is!)
It works fine and mypy does not complain
def test_account_list(data): mock_storage = mock.Mock() mock_storage.account_list.return_value = data
storage = cast(Storage, mock_storage)
result = data_source.account_list(storage)
mock_storage.account_list.assert_called_with()
assert result == data