Skip to content

Commit abed8ee

Browse files
authored
Merge branch 'main' into fix-linter-ruff
2 parents 2d423c5 + d6a1b5d commit abed8ee

20 files changed

+71
-49
lines changed

newrelic/admin/run_python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def log_message(text, *args):
7474

7575
if "PYTHONPATH" in os.environ:
7676
path = os.environ["PYTHONPATH"].split(os.path.pathsep)
77-
if not boot_directory in path:
77+
if boot_directory not in path:
7878
python_path = f"{boot_directory}{os.path.pathsep}{os.environ['PYTHONPATH']}"
7979

8080
os.environ["PYTHONPATH"] = python_path

newrelic/api/background_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def wrapper(wrapped, instance, args, kwargs):
7272
else:
7373
_group = group
7474

75-
if type(application) != Application:
75+
if type(application) is not Application:
7676
_application = application_instance(application)
7777
else:
7878
_application = application

newrelic/api/message_transaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def create_transaction(transaction):
190190

191191
return None
192192

193-
if type(application) != Application:
193+
if type(application) is not Application:
194194
_application = application_instance(application)
195195
else:
196196
_application = application

newrelic/api/web_transaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ def WebTransactionWrapper(
799799
source=None,
800800
):
801801
def wrapper(wrapped, instance, args, kwargs):
802-
if type(application) != Application:
802+
if type(application) is not Application:
803803
_application = application_instance(application)
804804
else:
805805
_application = application

newrelic/api/wsgi_application.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def process_data(self, data):
201201
# works then we are done, else we move to next phase of
202202
# buffering up content until we find the body element.
203203

204-
html_to_be_inserted = lambda: self.transaction.browser_timing_header().encode("latin-1")
204+
def html_to_be_inserted():
205+
return self.transaction.browser_timing_header().encode("latin-1")
206+
205207
if not self.response_data:
206208
modified = insert_html_snippet(data, html_to_be_inserted)
207209

newrelic/common/utilization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def fetchAuthToken(cls):
181181
def fetch(cls):
182182
try:
183183
authToken = cls.fetchAuthToken()
184-
if authToken == None:
184+
if authToken is None:
185185
return
186186
cls.HEADERS = {"X-aws-ec2-metadata-token": authToken}
187187
with cls.CLIENT_CLS(cls.METADATA_HOST, timeout=cls.FETCH_TIMEOUT) as client:

newrelic/console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def __socket_cleanup(self, path):
442442
pass
443443

444444
def __thread_run(self):
445-
if type(self.__listener_socket) == type(()):
445+
if type(self.__listener_socket) is tuple:
446446
listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
447447
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
448448
listener.bind(self.__listener_socket)

newrelic/core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def _environ_as_bool(name, default=False):
553553
flag = os.environ.get(name, default)
554554
if default is None or default:
555555
try:
556-
flag = not flag.lower() in ["off", "false", "0"]
556+
flag = flag.lower() not in ["off", "false", "0"]
557557
except AttributeError:
558558
pass
559559
else:

newrelic/core/internal_metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __exit__(self, exc, value, tb):
4343

4444
class InternalTraceWrapper:
4545
def __init__(self, wrapped, name):
46-
if type(wrapped) == type(()):
46+
if type(wrapped) is tuple:
4747
(instance, wrapped) = wrapped
4848
else:
4949
instance = None

newrelic/core/stack_trace.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def _format_stack_trace(frames):
3232
return result
3333

3434

35-
def _extract_stack(f, skip, limit):
36-
if f is None:
35+
def _extract_stack(frame, skip, limit):
36+
if frame is None:
3737
return []
3838

3939
# For calculating the stack trace we have the bottom most frame we
@@ -42,21 +42,21 @@ def _extract_stack(f, skip, limit):
4242
# order we want as it is more efficient.
4343

4444
n = 0
45-
l = []
45+
frame_list = []
4646

47-
while f is not None and skip > 0:
48-
f = f.f_back
47+
while frame is not None and skip > 0:
48+
frame = frame.f_back
4949
skip -= 1
5050

51-
while f is not None and n < limit:
52-
l.append(dict(source=f.f_code.co_filename, line=f.f_lineno, name=f.f_code.co_name))
51+
while frame is not None and n < limit:
52+
frame_list.append({"source": frame.f_code.co_filename, "line": frame.f_lineno, "name": frame.f_code.co_name})
5353

54-
f = f.f_back
54+
frame = frame.f_back
5555
n += 1
5656

57-
l.reverse()
57+
frame_list.reverse()
5858

59-
return l
59+
return frame_list
6060

6161

6262
def current_stack(skip=0, limit=None):
@@ -66,9 +66,9 @@ def current_stack(skip=0, limit=None):
6666
try:
6767
raise ZeroDivisionError
6868
except ZeroDivisionError:
69-
f = sys.exc_info()[2].tb_frame.f_back
69+
frame = sys.exc_info()[2].tb_frame.f_back
7070

71-
return _format_stack_trace(_extract_stack(f, skip, limit))
71+
return _format_stack_trace(_extract_stack(frame, skip, limit))
7272

7373

7474
def _extract_tb(tb, limit):
@@ -93,21 +93,21 @@ def _extract_tb(tb, limit):
9393
n += 1
9494

9595
n = 0
96-
l = []
96+
frame_list = []
9797

9898
# We have now the top traceback object for the limit of what we are
9999
# to return. The bottom most will be that where the error occurred.
100100

101101
tb = top
102102

103103
while tb is not None and n < limit:
104-
f = tb.tb_frame
105-
l.append(dict(source=f.f_code.co_filename, line=tb.tb_lineno, name=f.f_code.co_name))
104+
frame = tb.tb_frame
105+
frame_list.append({"source": frame.f_code.co_filename, "line": tb.tb_lineno, "name": frame.f_code.co_name})
106106

107107
tb = tb.tb_next
108108
n += 1
109109

110-
return l
110+
return frame_list
111111

112112

113113
def exception_stack(tb, limit=None):

0 commit comments

Comments
 (0)