Skip to content

Commit

Permalink
revert getattr fix (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
thehesiod committed Jun 4, 2020
1 parent 725cb1f commit d4ce2d9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changes
-------

1.0.6 (2020-06-04)
^^^^^^^^^^^^^^^^^^
* revert __getattr__ fix as it breaks ddtrace

1.0.5 (2020-06-03)
^^^^^^^^^^^^^^^^^^
* Fixed AioSession.get_service_data emit call #811 via #812
Expand Down
2 changes: 1 addition & 1 deletion aiobotocore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .session import get_session, AioSession

__all__ = ['get_session', 'AioSession']
__version__ = '1.0.5'
__version__ = '1.0.6'
38 changes: 5 additions & 33 deletions aiobotocore/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import asyncio

from botocore.awsrequest import prepare_request_dict
from botocore.client import logger, PaginatorDocstring, ClientCreator, \
BaseClient, ClientEndpointBridge
Expand Down Expand Up @@ -71,36 +69,6 @@ def _get_client_args(self, service_model, region_name, is_secure,
verify, credentials, scoped_config, client_config, endpoint_bridge)


class _AsyncAttrAdapter:
def __init__(self, coro):
self._coro = coro
self._args = None
self._kwargs = None

def __call__(self, *args, **kwargs):
# bind args
self._args = args
self._kwargs = kwargs
return self

async def _resolve(self):
event_response = await self._coro
if asyncio.iscoroutinefunction(event_response):
result = await event_response(*self._args, **self._kwargs)
return result

if callable(event_response):
result = event_response(*self._args, **self._kwargs)
if asyncio.iscoroutine(result):
result = await result
return result

return event_response

def __await__(self):
return self._resolve().__await__()


class AioBaseClient(BaseClient):
async def _async_getattr(self, item):
event_name = 'getattr.%s.%s' % (
Expand All @@ -112,7 +80,11 @@ async def _async_getattr(self, item):
return event_response

def __getattr__(self, item):
return _AsyncAttrAdapter(self._async_getattr(item))
# NOTE: we can not reliably support this because if we were to make this a
# deferred attrgetter (See #803), it would resolve in hasattr always returning
# true. This ends up breaking ddtrace for example when it tries to set a pin.
raise AttributeError(
"'%s' object has no attribute '%s'" % (self.__class__.__name__, item))

async def _make_api_call(self, operation_name, api_params):
operation_model = self._service_model.operation_model(operation_name)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_mturk.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@


# Unfortunately moto does not support mturk yet
@pytest.mark.moto
# Also looks like we won't be able to support this (see notes from 1.0.6 release)
# @pytest.mark.moto
@pytest.mark.asyncio
async def test_mturk_stubber(session):
async with session.create_client('mturk', region_name='us-east-1') as client:
Expand Down

0 comments on commit d4ce2d9

Please sign in to comment.