Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 30d1c62

Browse files
sagivr2020maorlx
andauthored
feat(lambda): add support for python 3.10 (#403)
* [CS-190]: Add Support for Python 3.10 * fix(lint): handle exception type specified * fix(requirements): wrapt version * fix(travis): pip version * fix(travis): revert pip version * fix(requirements): autowrapt no specific version * fix(requirements): place autowrapt as first * fix(travis): specific pip version * fix(travis): specific pip version * fix(requirements): pytest version for python 3_7 * fix(requirements): pytest version for python 3_7 * fix(requirements): pytest version for python 3_7 * fix(travis): remove install pip specific version * fix(travis): add install pip specific version * Revert fix attempts * Revert fix attempts * Fix call to self test flask Co-authored-by: maorlx <maorlevi@cisco.com>
1 parent 505b092 commit 30d1c62

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ before_install:
1111
- nvm use 12
1212

1313
install:
14+
- pip install -U importlib-metadata
15+
- pip install -U pluggy
1416
- pip install -r requirements-dev.txt
1517

1618
script:

epsagon/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
from __future__ import absolute_import, print_function
66
import os
7-
import collections
7+
try:
8+
from collections import Mapping, Iterable
9+
except: # pylint: disable=W0702
10+
from collections.abc import Mapping, Iterable
811
import uuid
912
import socket
1013
import sys
@@ -333,13 +336,13 @@ def find_in_object(obj, key, path=None):
333336
if not path:
334337
path = []
335338

336-
if isinstance(obj, collections.Mapping):
339+
if isinstance(obj, Mapping):
337340
# search key in obj
338341
if key in obj:
339342
return obj[key], path
340343

341344
if (
342-
isinstance(obj, collections.Iterable)
345+
isinstance(obj, Iterable)
343346
and not isinstance(obj, six.string_types)
344347
):
345348
for k in obj:

epsagon/wrappers/aws_lambda.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
import copy
1212
import functools
1313
import warnings
14-
import collections
14+
try:
15+
from collections import Mapping
16+
except: # pylint: disable=W0702
17+
from collections.abc import Mapping
1518
from uuid import uuid4
1619

1720
import epsagon.trace
@@ -32,7 +35,7 @@ def _add_status_code(runner, return_value):
3235
:param runner: Runner event to update
3336
:param return_value: The return value to extract from
3437
"""
35-
if isinstance(return_value, collections.Mapping):
38+
if isinstance(return_value, Mapping):
3639
status_code = return_value.get('statusCode')
3740
if status_code:
3841
runner.resource['metadata']['status_code'] = status_code

epsagon/wrappers/tencent_function.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import time
88
import functools
99
import warnings
10-
import collections
10+
try:
11+
from collections import Mapping
12+
except: # pylint: disable=W0702
13+
from collections.abc import Mapping
1114

1215
import epsagon.trace
1316
import epsagon.runners.tencent_function
@@ -26,7 +29,7 @@ def _add_status_code(runner, return_value):
2629
:param runner: Runner event to update
2730
:param return_value: The return value to extract from
2831
"""
29-
if isinstance(return_value, collections.Mapping):
32+
if isinstance(return_value, Mapping):
3033
status_code = return_value.get('statusCode')
3134
if status_code:
3235
runner.resource['metadata']['status_code'] = status_code

tests/wrappers/test_flask_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def self_call():
6565

6666
if not inner_call:
6767
return CLIENT.post('/self_call', json={
68-
'inner_call': 'True'
68+
'inner_call': True
6969
})
7070

7171
return RETURN_VALUE
@@ -179,7 +179,7 @@ def test_call_to_self(trace_transport, client):
179179
And API that calls itself. Make sure instrumentation doesn't throw
180180
and exception that gets to the user.
181181
"""
182-
result = CLIENT.post('/self_call')
182+
result = CLIENT.post('/self_call', json={})
183183
assert result.data.decode('ascii') == RETURN_VALUE
184184

185185

0 commit comments

Comments
 (0)