Skip to content

Commit

Permalink
Fix more pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lrafeei committed Oct 12, 2022
1 parent 8690fe3 commit 807ec1c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion newrelic/admin/validate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def validate_config(args):

if not _application.active:
_logger.error(
"Unable to register application for test, " "connection could not be established within %s seconds.",
"Unable to register application for test, connection could not be established within %s seconds.",
_timeout,
)
return
Expand Down
15 changes: 8 additions & 7 deletions newrelic/api/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from collections import OrderedDict

import newrelic.core.database_node
import newrelic.core.error_node
import newrelic.core.root_node
import newrelic.core.transaction_node
from newrelic.api.application import application_instance
Expand Down Expand Up @@ -61,6 +60,7 @@
)
from newrelic.core.config import DEFAULT_RESERVOIR_SIZE, LOG_EVENT_RESERVOIR_SIZE
from newrelic.core.custom_event import create_custom_event
from newrelic.core.error_node import ErrorNode
from newrelic.core.log_event_node import LogEventNode
from newrelic.core.stack_trace import exception_stack
from newrelic.core.stats_engine import CustomMetrics, SampledDataSet
Expand Down Expand Up @@ -1558,7 +1558,7 @@ def _create_error_node(self, settings, fullname, message, expected, custom_param
if error.type == fullname and error.message == message:
return

node = newrelic.core.error_node.ErrorNode(
node = ErrorNode(
timestamp=time.time(),
type=fullname,
message=message,
Expand Down Expand Up @@ -1609,7 +1609,8 @@ def _process_node(self, node):
node.node_count = self._trace_node_count
self.total_time += node.exclusive

if type(node) is newrelic.core.database_node.DatabaseNode:
# if type(node) is newrelic.core.database_node.DatabaseNode:
if isinstance(newrelic.core.database_node.DatabaseNode, ErrorNode):
settings = self._settings
if not settings:
return
Expand Down Expand Up @@ -1675,15 +1676,15 @@ def add_custom_attributes(self, items):
def add_custom_parameter(self, name, value):
# Deprecation warning
warnings.warn(
("The add_custom_parameter API has been deprecated. " "Please use the add_custom_attribute API."),
("The add_custom_parameter API has been deprecated. Please use the add_custom_attribute API."),
DeprecationWarning,
)
return self.add_custom_attribute(name, value)

def add_custom_parameters(self, items):
# Deprecation warning
warnings.warn(
("The add_custom_parameters API has been deprecated. " "Please use the add_custom_attributes API."),
("The add_custom_parameters API has been deprecated. Please use the add_custom_attributes API."),
DeprecationWarning,
)
return self.add_custom_attributes(items)
Expand Down Expand Up @@ -1779,7 +1780,7 @@ def add_custom_attributes(items):
def add_custom_parameter(key, value):
# Deprecation warning
warnings.warn(
("The add_custom_parameter API has been deprecated. " "Please use the add_custom_attribute API."),
("The add_custom_parameter API has been deprecated. Please use the add_custom_attribute API."),
DeprecationWarning,
)
return add_custom_attribute(key, value)
Expand All @@ -1788,7 +1789,7 @@ def add_custom_parameter(key, value):
def add_custom_parameters(items):
# Deprecation warning
warnings.warn(
("The add_custom_parameter API has been deprecated. " "Please use the add_custom_attribute API."),
("The add_custom_parameter API has been deprecated. Please use the add_custom_attribute API."),
DeprecationWarning,
)
return add_custom_attributes(items)
Expand Down
14 changes: 6 additions & 8 deletions newrelic/core/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,19 @@ def process_user_attribute(name, value, max_length=MAX_ATTRIBUTE_LENGTH, ending=
value = sanitize(value)

except NameIsNotStringException:
_logger.debug("Attribute name must be a string. Dropping " "attribute: %r=%r", name, value)
_logger.debug("Attribute name must be a string. Dropping attribute: %r=%r", name, value)
return FAILED_RESULT

except NameTooLongException:
_logger.debug("Attribute name exceeds maximum length. Dropping " "attribute: %r=%r", name, value)
_logger.debug("Attribute name exceeds maximum length. Dropping attribute: %r=%r", name, value)
return FAILED_RESULT

except IntTooLargeException:
_logger.debug("Attribute value exceeds maximum integer value. " "Dropping attribute: %r=%r", name, value)
_logger.debug("Attribute value exceeds maximum integer value. Dropping attribute: %r=%r", name, value)
return FAILED_RESULT

except CastingFailureException:
_logger.debug("Attribute value cannot be cast to a string. " "Dropping attribute: %r=%r", name, value)
_logger.debug("Attribute value cannot be cast to a string. Dropping attribute: %r=%r", name, value)
return FAILED_RESULT

else:
Expand All @@ -268,7 +268,7 @@ def process_user_attribute(name, value, max_length=MAX_ATTRIBUTE_LENGTH, ending=
trunc_value = truncate(value, maxsize=max_length, ending=ending)
if value != trunc_value:
_logger.debug(
"Attribute value exceeds maximum length " "(%r bytes). Truncating value: %r=%r.",
"Attribute value exceeds maximum length (%r bytes). Truncating value: %r=%r.",
max_length,
name,
trunc_value,
Expand Down Expand Up @@ -296,8 +296,6 @@ def sanitize(value):
except Exception:
raise CastingFailureException()
else:
_logger.debug(
"Attribute value is of type: %r. Casting %r to " "string: %s", type(original), original, value
)
_logger.debug("Attribute value is of type: %r. Casting %r to string: %s", type(original), original, value)

return value
9 changes: 5 additions & 4 deletions tests/agent_features/test_span_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,11 @@ def _test():
@pytest.mark.parametrize("span_events_enabled", (False, True))
def test_collect_span_events_override(collect_span_events, span_events_enabled):

if collect_span_events and span_events_enabled:
spans_expected = True
else:
spans_expected = False
# if collect_span_events and span_events_enabled:
# spans_expected = True
# else:
# spans_expected = False
spans_expected = collect_span_events and span_events_enabled

span_count = 2 if spans_expected else 0

Expand Down
4 changes: 2 additions & 2 deletions tests/testing_support/sample_asgi_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def __call__(self, receive, send):

if self.scope["path"] == "/exc":
raise ValueError("whoopsies")
elif self.scope["path"] == "/ignored":
if self.scope["path"] == "/ignored":
ignore_transaction()

await send({"type": "http.response.start", "status": 200})
Expand All @@ -57,7 +57,7 @@ async def simple_app_v3_raw(scope, receive, send):

if scope["path"] == "/exc":
raise ValueError("whoopsies")
elif scope["path"] == "/ignored":
if scope["path"] == "/ignored":
ignore_transaction()

await send({"type": "http.response.start", "status": 200})
Expand Down

0 comments on commit 807ec1c

Please sign in to comment.