Skip to content

Commit b114fdc

Browse files
committed
Remove string_types from compat module
1 parent 02b0ee8 commit b114fdc

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

aws_xray_sdk/core/models/entity.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import json
88

9-
from ..utils.compat import annotation_value_types, string_types
9+
from ..utils.compat import annotation_value_types
1010
from ..utils.conversion import metadata_to_dict
1111
from .throwable import Throwable
1212
from . import http
@@ -113,7 +113,7 @@ def put_http_meta(self, key, value):
113113
return
114114

115115
if key == http.STATUS:
116-
if isinstance(value, string_types):
116+
if isinstance(value, str):
117117
value = int(value)
118118
self.apply_status_code(value)
119119

@@ -139,7 +139,7 @@ def put_annotation(self, key, value):
139139
"""
140140
self._check_ended()
141141

142-
if not isinstance(key, string_types):
142+
if not isinstance(key, str):
143143
log.warning("ignoring non string type annotation key with type %s.", type(key))
144144
return
145145

@@ -165,7 +165,7 @@ def put_metadata(self, key, value, namespace='default'):
165165
"""
166166
self._check_ended()
167167

168-
if not isinstance(namespace, string_types):
168+
if not isinstance(namespace, str):
169169
log.warning("ignoring non string type metadata namespace")
170170
return
171171

@@ -271,7 +271,7 @@ def serialize(self):
271271
def to_dict(self):
272272
"""
273273
Convert Entity(Segment/Subsegment) object to dict
274-
with required properties that have non-empty values.
274+
with required properties that have non-empty values.
275275
"""
276276
entity_dict = {}
277277

aws_xray_sdk/core/models/throwable.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import binascii
44
import logging
55

6-
from ..utils.compat import string_types
7-
86
log = logging.getLogger(__name__)
97

108

@@ -31,7 +29,7 @@ def __init__(self, exception, stack, remote=False):
3129
message = None
3230

3331
# do not record non-string exception message
34-
if isinstance(message, string_types):
32+
if isinstance(message, str):
3533
self.message = message
3634

3735
self.type = type(exception).__name__

aws_xray_sdk/core/recorder.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from .plugins.utils import get_plugin_modules
1919
from .lambda_launcher import check_in_lambda
2020
from .exceptions.exceptions import SegmentNameMissingException, SegmentNotFoundException
21-
from .utils.compat import string_types
2221
from .utils import stacktrace
2322

2423
log = logging.getLogger(__name__)
@@ -288,7 +287,7 @@ def _begin_subsegment_helper(self, name, namespace='local', beginWithoutSampling
288287
if not segment:
289288
log.warning("No segment found, cannot begin subsegment %s." % name)
290289
return None
291-
290+
292291
current_entity = self.get_trace_entity()
293292
if not current_entity.sampled or beginWithoutSampling:
294293
subsegment = DummySubsegment(segment, name)
@@ -486,7 +485,7 @@ def _populate_runtime_context(self, segment, sampling_decision):
486485
segment.set_aws(copy.deepcopy(self._aws_metadata))
487486
segment.set_service(SERVICE_INFO)
488487

489-
if isinstance(sampling_decision, string_types):
488+
if isinstance(sampling_decision, str):
490489
segment.set_rule_name(sampling_decision)
491490

492491
def _send_segment(self):
@@ -562,7 +561,7 @@ def dynamic_naming(self):
562561

563562
@dynamic_naming.setter
564563
def dynamic_naming(self, value):
565-
if isinstance(value, string_types):
564+
if isinstance(value, str):
566565
self._dynamic_naming = DefaultDynamicNaming(value, self.service)
567566
else:
568567
self._dynamic_naming = value

aws_xray_sdk/core/utils/compat.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import inspect
22

33
annotation_value_types = (int, float, bool, str)
4-
string_types = str
54

65

76
def is_classmethod(func):

0 commit comments

Comments
 (0)