1111
1212from IPython .core .getipython import get_ipython
1313
14- from .jsonutil import json_clean
15-
1614# This import is required to have the next ones working...
17- from debugpy .server import api
15+ from debugpy .server import api # noqa
1816from _pydevd_bundle import pydevd_frame_utils
1917from _pydevd_bundle .pydevd_suspended_frames import SuspendedFramesManager , _FramesTracker
2018
2119# Required for backwards compatiblity
2220ROUTING_ID = getattr (zmq , 'ROUTING_ID' , None ) or zmq .IDENTITY
2321
22+
2423class _FakeCode :
2524 def __init__ (self , co_filename , co_name ):
2625 self .co_filename = co_filename
2726 self .co_name = co_name
2827
28+
2929class _FakeFrame :
3030 def __init__ (self , f_code , f_globals , f_locals ):
3131 self .f_code = f_code
3232 self .f_globals = f_globals
3333 self .f_locals = f_locals
3434 self .f_back = None
3535
36+
3637class _DummyPyDB :
3738 def __init__ (self ):
3839 from _pydevd_bundle .pydevd_api import PyDevdAPI
3940 self .variable_presentation = PyDevdAPI .VariablePresentation ()
4041
42+
4143class VariableExplorer :
4244 def __init__ (self ):
4345 self .suspended_frame_manager = SuspendedFramesManager ()
@@ -60,6 +62,7 @@ def get_children_variables(self, variable_ref = None):
6062 variables = self .suspended_frame_manager .get_variable (var_ref )
6163 return [x .get_var_data () for x in variables .get_children_variables ()]
6264
65+
6366class DebugpyMessageQueue :
6467
6568 HEADER = 'Content-Length: '
@@ -102,7 +105,7 @@ def put_tcp_frame(self, frame):
102105 self .header_pos = self .tcp_buffer .find (DebugpyMessageQueue .HEADER )
103106 if self .header_pos == - 1 :
104107 return
105-
108+
106109 self .log .debug ('QUEUE - found header at pos %i' , self .header_pos )
107110
108111 #Finds separator
@@ -138,7 +141,7 @@ def put_tcp_frame(self, frame):
138141
139142 async def get_message (self ):
140143 return await self .message_queue .get ()
141-
144+
142145
143146class DebugpyClient :
144147
@@ -175,7 +178,7 @@ def _send_request(self, msg):
175178 self .log .debug (self .routing_id )
176179 self .log .debug (buf )
177180 self .debugpy_stream .send_multipart ((self .routing_id , buf ))
178-
181+
179182 async def _wait_for_response (self ):
180183 # Since events are never pushed to the message_queue
181184 # we can safely assume the next message in queue
@@ -185,7 +188,7 @@ async def _wait_for_response(self):
185188 async def _handle_init_sequence (self ):
186189 # 1] Waits for initialized event
187190 await self .init_event .wait ()
188-
191+
189192 # 2] Sends configurationDone request
190193 configurationDone = {
191194 'type' : 'request' ,
@@ -246,7 +249,7 @@ class Debugger:
246249 'variables' , 'attach' ,
247250 'configurationDone'
248251 ]
249-
252+
250253 # Requests that can be handled even if the debugger is not running
251254 static_debug_msg_types = [
252255 'debugInfo' , 'inspectVariables' , 'richInspectVariables'
@@ -259,7 +262,7 @@ def __init__(self, log, debugpy_stream, event_callback, shell_socket, session):
259262 self .session = session
260263 self .is_started = False
261264 self .event_callback = event_callback
262-
265+
263266 self .started_debug_handlers = {}
264267 for msg_type in Debugger .started_debug_msg_types :
265268 self .started_debug_handlers [msg_type ] = getattr (self , msg_type )
@@ -324,7 +327,7 @@ def start(self):
324327 }
325328 self .session .send (self .shell_socket , 'execute_request' , content ,
326329 None , (self .shell_socket .getsockopt (ROUTING_ID )))
327-
330+
328331 ident , msg = self .session .recv (self .shell_socket , mode = 0 )
329332 self .debugpy_initialized = msg ['content' ]['status' ] == 'ok'
330333 self .debugpy_client .connect_tcp_socket ()
@@ -517,7 +520,7 @@ async def richInspectVariables(self, message):
517520 'arguments' : {
518521 'expression' : lvalue ,
519522 'value' : code ,
520- 'frameId' : frameId
523+ 'frameId' : frame_id
521524 }
522525 }
523526 await self ._forward_message (request )
@@ -535,10 +538,10 @@ async def richInspectVariables(self, message):
535538 'data' : {},
536539 'metadata' : {}
537540 }
538-
541+
539542 for key , value in repr_data .items ():
540543 body ['data' ]['key' ] = value
541- if repr_metadata . has_key ( key ) :
544+ if key in repr_metadata :
542545 body ['metadata' ][key ] = repr_metadata [key ]
543546
544547 globals ().pop (var_repr_data )
0 commit comments