diff --git a/ddtrace/contrib/pyramid/patch.py b/ddtrace/contrib/pyramid/patch.py index 3e39d66a41d0..7250eb0f7174 100644 --- a/ddtrace/contrib/pyramid/patch.py +++ b/ddtrace/contrib/pyramid/patch.py @@ -78,7 +78,7 @@ def insert_tween_if_needed(settings): # pyramid. We need our tween to be before it, otherwise unhandled # exceptions will be caught before they reach our tween. idx = tweens.find(pyramid.tweens.EXCVIEW) - if idx is -1: + if idx == -1: settings['pyramid.tweens'] = tweens + '\n' + DD_TWEEN_NAME else: settings['pyramid.tweens'] = tweens[:idx] + DD_TWEEN_NAME + "\n" + tweens[idx:] diff --git a/ddtrace/contrib/tornado/__init__.py b/ddtrace/contrib/tornado/__init__.py index 76c73c2fbab0..9b7c9c106aad 100644 --- a/ddtrace/contrib/tornado/__init__.py +++ b/ddtrace/contrib/tornado/__init__.py @@ -58,7 +58,7 @@ def notify(self): 'analytics_enabled': False, 'settings': { 'FILTERS': [ - FilterRequestsOnUrl(r'http://test\.example\.com'), + FilterRequestsOnUrl(r'http://test\\.example\\.com'), ], }, }, diff --git a/ddtrace/filters.py b/ddtrace/filters.py index b6abef2e5f1f..9d2ebde015cc 100644 --- a/ddtrace/filters.py +++ b/ddtrace/filters.py @@ -18,15 +18,15 @@ class FilterRequestsOnUrl(object): To filter out http calls to domain api.example.com:: - FilterRequestsOnUrl(r'http://api\.example\.com') + FilterRequestsOnUrl(r'http://api\\.example\\.com') To filter out http calls to all first level subdomains from example.com:: - FilterRequestOnUrl(r'http://.*+\.example\.com') + FilterRequestOnUrl(r'http://.*+\\.example\\.com') To filter out calls to both http://test.example.com and http://example.com/healthcheck:: - FilterRequestOnUrl([r'http://test\.example\.com', r'http://example\.com/healthcheck']) + FilterRequestOnUrl([r'http://test\\.example\\.com', r'http://example\\.com/healthcheck']) """ def __init__(self, regexps): if isinstance(regexps, str): diff --git a/ddtrace/monkey.py b/ddtrace/monkey.py index cb468b9cfd24..f5989e1e3bd6 100644 --- a/ddtrace/monkey.py +++ b/ddtrace/monkey.py @@ -96,7 +96,7 @@ def on_import(hook): def patch_all(**patch_modules): """Automatically patches all available modules. - :param dict \**patch_modules: Override whether particular modules are patched or not. + :param dict patch_modules: Override whether particular modules are patched or not. >>> patch_all(redis=False, cassandra=False) """ @@ -110,7 +110,7 @@ def patch(raise_errors=True, **patch_modules): """Patch only a set of given modules. :param bool raise_errors: Raise error if one patch fail. - :param dict \**patch_modules: List of modules to patch. + :param dict patch_modules: List of modules to patch. >>> patch(psycopg=True, elasticsearch=True) """ diff --git a/ddtrace/pin.py b/ddtrace/pin.py index 838bed50396f..74ee55700a98 100644 --- a/ddtrace/pin.py +++ b/ddtrace/pin.py @@ -48,7 +48,7 @@ def service(self): return self._config['service_name'] def __setattr__(self, name, value): - if getattr(self, '_initialized', False) and name is not '_target': + if getattr(self, '_initialized', False) and name != '_target': raise AttributeError("can't mutate a pin, use override() or clone() instead") super(Pin, self).__setattr__(name, value) diff --git a/tests/contrib/dbapi/test_unit.py b/tests/contrib/dbapi/test_unit.py index 7a5fcecda376..57de37318fcd 100644 --- a/tests/contrib/dbapi/test_unit.py +++ b/tests/contrib/dbapi/test_unit.py @@ -3,6 +3,7 @@ from ddtrace import Pin from ddtrace.constants import ANALYTICS_SAMPLE_RATE_KEY from ddtrace.contrib.dbapi import FetchTracedCursor, TracedCursor, TracedConnection +from ddtrace.span import Span from ...base import BaseTracerTestCase diff --git a/tests/contrib/falcon/test_distributed_tracing.py b/tests/contrib/falcon/test_distributed_tracing.py index ff7a0977ba55..063505a590e0 100644 --- a/tests/contrib/falcon/test_distributed_tracing.py +++ b/tests/contrib/falcon/test_distributed_tracing.py @@ -49,5 +49,5 @@ def test_distributred_tracing_disabled(self): eq_(len(traces), 1) eq_(len(traces[0]), 1) - ok_(traces[0][0].parent_id is not 42) - ok_(traces[0][0].trace_id is not 100) + ok_(traces[0][0].parent_id != 42) + ok_(traces[0][0].trace_id != 100) diff --git a/tests/contrib/httplib/test_httplib.py b/tests/contrib/httplib/test_httplib.py index 2485c14dc102..3a270d58e832 100644 --- a/tests/contrib/httplib/test_httplib.py +++ b/tests/contrib/httplib/test_httplib.py @@ -351,6 +351,7 @@ def test_httplib_request_and_response_headers(self): # Enabled when configured with self.override_config('hhtplib', {}): + from ddtrace.settings import IntegrationConfig integration_config = config.httplib # type: IntegrationConfig integration_config.http.trace_headers(['my-header', 'access-control-allow-origin']) conn = self.get_http_connection(SOCKET) diff --git a/tests/contrib/tornado/test_stack_context.py b/tests/contrib/tornado/test_stack_context.py index 79d3b05ea409..22f9643e5436 100644 --- a/tests/contrib/tornado/test_stack_context.py +++ b/tests/contrib/tornado/test_stack_context.py @@ -45,5 +45,5 @@ def test_propagation_without_stack_context(self): traces = self.tracer.writer.pop_traces() eq_(len(traces), 1) eq_(len(traces[0]), 1) - ok_(traces[0][0].trace_id is not 100) - ok_(traces[0][0].parent_id is not 101) + ok_(traces[0][0].trace_id != 100) + ok_(traces[0][0].parent_id != 101) diff --git a/tests/opentracer/test_tracer.py b/tests/opentracer/test_tracer.py index 0fa306d390da..b757e4b53f08 100644 --- a/tests/opentracer/test_tracer.py +++ b/tests/opentracer/test_tracer.py @@ -301,7 +301,7 @@ def test_start_active_span_child_finish_after_parent(self, ot_tracer, writer): span2.finish() spans = writer.pop() - assert len(spans) is 2 + assert len(spans) == 2 assert spans[0].parent_id is None assert spans[1].parent_id is span1._dd_span.span_id assert spans[1].duration > spans[0].duration diff --git a/tests/test_filters.py b/tests/test_filters.py index 162d0c190870..d4baacc9b7b1 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -23,13 +23,13 @@ def test_is_not_match(self): def test_list_match(self): span = Span(name='Name', tracer=None) span.set_tag(URL, r'http://anotherdomain.example.com') - filtr = FilterRequestsOnUrl(['http://domain\.example\.com', 'http://anotherdomain\.example\.com']) + filtr = FilterRequestsOnUrl([r'http://domain\.example\.com', r'http://anotherdomain\.example\.com']) trace = filtr.process_trace([span]) self.assertIsNone(trace) def test_list_no_match(self): span = Span(name='Name', tracer=None) span.set_tag(URL, r'http://cooldomain.example.com') - filtr = FilterRequestsOnUrl(['http://domain\.example\.com', 'http://anotherdomain\.example\.com']) + filtr = FilterRequestsOnUrl([r'http://domain\.example\.com', r'http://anotherdomain\.example\.com']) trace = filtr.process_trace([span]) self.assertIsNotNone(trace) diff --git a/tox.ini b/tox.ini index c5ead3bc0bf9..878263d5fe7c 100644 --- a/tox.ini +++ b/tox.ini @@ -394,7 +394,7 @@ deps= ignore_outcome=true [testenv:flake8] -deps=flake8==3.5.0 +deps=flake8>=3.7,<=3.8 commands=flake8 . basepython=python2