diff --git a/python3/vimspector/breakpoints.py b/python3/vimspector/breakpoints.py index e15a649..0cc1d06 100644 --- a/python3/vimspector/breakpoints.py +++ b/python3/vimspector/breakpoints.py @@ -100,7 +100,7 @@ class ProjectBreakpoints( object ): return found_bp = False - for index, bp in enumerate( self._line_breakpoints[ file_name] ): + for index, bp in enumerate( self._line_breakpoints[ file_name ] ): if bp[ 'line' ] == line: found_bp = True if bp[ 'state' ] == 'ENABLED': @@ -151,7 +151,7 @@ class ProjectBreakpoints( object ): def SendBreakpoints( self ): if not self._breakpoints_handler: def handler( source, msg ): - return self._ShowBreakpoints() + return self._ShowBreakpoints() else: handler = self._breakpoints_handler diff --git a/python3/vimspector/code.py b/python3/vimspector/code.py index 9aa85da..e38f840 100644 --- a/python3/vimspector/code.py +++ b/python3/vimspector/code.py @@ -21,7 +21,7 @@ from collections import defaultdict from vimspector import utils -class CodeView( object ): +class CodeView( object ): def __init__( self, window ): self._window = window @@ -78,9 +78,9 @@ class CodeView( object ): vim.command( 'sign place {0} group=VimspectorCode priority=20 ' 'line={1} name=vimspectorPC ' 'file={2}'.format( - self._signs[ 'vimspectorPC' ], - frame[ 'line' ], - frame[ 'source' ][ 'path' ] ) ) + self._signs[ 'vimspectorPC' ], + frame[ 'line' ], + frame[ 'source' ][ 'path' ] ) ) return True @@ -166,11 +166,11 @@ class CodeView( object ): 'line={1} ' 'name={2} ' 'file={3}'.format( - sign_id, - breakpoint[ 'line' ], - 'vimspectorBP' if breakpoint[ 'verified' ] - else 'vimspectorBPDisabled', - file_name ) ) + sign_id, + breakpoint[ 'line' ], + 'vimspectorBP' if breakpoint[ 'verified' ] + else 'vimspectorBPDisabled', + file_name ) ) def BreakpointsAsQuickFix( self ): diff --git a/python3/vimspector/debug_adapter_connection.py b/python3/vimspector/debug_adapter_connection.py index 844bb23..73a4549 100644 --- a/python3/vimspector/debug_adapter_connection.py +++ b/python3/vimspector/debug_adapter_connection.py @@ -190,7 +190,7 @@ class DebugAdapterConnection( object ): assert self._state == 'READ_BODY' return - payload = str( self._buffer[ : content_length ], 'utf-8' ) + payload = str( self._buffer[ : content_length ], 'utf-8' ) self._buffer = self._buffer[ content_length : ] # self._logger.debug( 'Message received (raw): %s', payload ) diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 581eb6b..5acef40 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -17,12 +17,9 @@ import logging import vim import json import os -import functools import subprocess import shlex -from collections import defaultdict - from vimspector import ( breakpoints, code, debug_adapter_connection, @@ -110,11 +107,11 @@ class DebugSession( object ): # set from an api call like SetLaunchParam( 'var', 'value' ), perhaps also a # way to load .vimspector.local.json which just sets variables self._variables = { - 'dollar': '$', # HACK + 'dollar': '$', # HACK. Hote '$$' also works. 'workspaceRoot': self._workspace_root, 'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ) } - self._variables.update( + self._variables.update( utils.ParseVariables( adapter.get( 'variables', {} ) ) ) self._variables.update( utils.ParseVariables( configuration.get( 'variables', {} ) ) ) @@ -125,7 +122,7 @@ class DebugSession( object ): if not adapter: utils.UserMessage( 'No adapter configured for {}'.format( - configuration_name ), persist=True ) + configuration_name ), persist=True ) return self._StartWithConfiguration( configuration, adapter ) @@ -174,7 +171,7 @@ class DebugSession( object ): # beeps and doesn't display the config selector. One option is to just not # display the selector and restart with the same opitons. if not self._configuration or not self._adapter: - return Start() + return self.Start() self._StartWithConfiguration( self._configuration, self._adapter ) @@ -420,7 +417,7 @@ class DebugSession( object ): atttach_config = adapter_config.get( 'attach' ) if not atttach_config: - return + return if 'remote' in atttach_config: # FIXME: We almost want this to feed-back variables to be expanded later, @@ -449,7 +446,7 @@ class DebugSession( object ): commands = self._GetCommands( remote, 'attach' ) for command in commands: - cmd = ssh + command[:] + cmd = ssh + command[ : ] for index, item in enumerate( cmd ): cmd[ index ] = item.replace( '%PID%', pid ) @@ -483,7 +480,7 @@ class DebugSession( object ): commands = self._GetCommands( remote, 'run' ) for index, command in enumerate( commands ): - cmd = ssh + command[:] + cmd = ssh + command[ : ] full_cmd = [] for item in cmd: if isinstance( command_line, list ): @@ -560,7 +557,7 @@ class DebugSession( object ): if request == "attach": self._PrepareAttach( adapter_config, launch_config ) elif request == "launch": - # FIXME: This cmdLine hack is not fun. + # FIXME: This cmdLine hack is not fun. self._PrepareLaunch( self._configuration.get( 'remote-cmdLine', [] ), adapter_config, launch_config ) diff --git a/python3/vimspector/install.py b/python3/vimspector/install.py index 280b07b..3e6de8f 100644 --- a/python3/vimspector/install.py +++ b/python3/vimspector/install.py @@ -16,6 +16,7 @@ import platform import os + def GetOS(): if platform.system() == 'Darwin': return 'macos' @@ -24,9 +25,11 @@ def GetOS(): else: return 'linux' + def GetGadgetDir( vimspector_base, OS ): return os.path.join( os.path.abspath( vimspector_base ), 'gadgets', OS ) + def GetGadgetConfigFile( vimspector_base ): return os.path.join( GetGadgetDir( vimspector_base, GetOS() ), '.gadgets.json' ) diff --git a/python3/vimspector/output.py b/python3/vimspector/output.py index fbeedce..6ca0971 100644 --- a/python3/vimspector/output.py +++ b/python3/vimspector/output.py @@ -83,7 +83,7 @@ class OutputView( object ): self._ShowOutput( category ) def ConnectionUp( self, connection ): - self._connection = connection + self._connection = connection def ConnectionClosed( self ): # Don't clear because output is probably still useful @@ -166,7 +166,7 @@ class OutputView( object ): if cmd is not None: out, err = utils.SetUpCommandBuffer( cmd, category ) self._buffers[ category + '-out' ] = TabBuffer( out, - len( self._buffers ) ) + len( self._buffers ) ) self._buffers[ category + '-out' ].is_job = True self._buffers[ category + '-err' ] = TabBuffer( err, len( self._buffers ) ) diff --git a/python3/vimspector/stack_trace.py b/python3/vimspector/stack_trace.py index 61f1d64..9849131 100644 --- a/python3/vimspector/stack_trace.py +++ b/python3/vimspector/stack_trace.py @@ -38,7 +38,7 @@ class StackTraceView( object ): self._line_to_thread = {} # TODO: We really need a proper state model - # + # # AWAIT_CONNECTION -- OnServerReady / RequestThreads --> REQUESTING_THREADS # REQUESTING -- OnGotThreads / RequestScopes --> REQUESTING_SCOPES # @@ -76,7 +76,7 @@ class StackTraceView( object ): pending_request = False if self._requesting_threads: pending_request = True - return + return def consume_threads( message ): self._requesting_threads = False diff --git a/python3/vimspector/utils.py b/python3/vimspector/utils.py index 4496e0e..6aad9e7 100644 --- a/python3/vimspector/utils.py +++ b/python3/vimspector/utils.py @@ -30,7 +30,7 @@ _log_handler.setFormatter( def SetUpLogging( logger ): logger.setLevel( logging.DEBUG ) if _log_handler not in logger.handlers: - logger.addHandler( _log_handler ) + logger.addHandler( _log_handler ) def BufferNumberForFile( file_name ): @@ -60,12 +60,12 @@ def SetUpCommandBuffer( cmd, name ): if bufs is None: raise RuntimeError( "Unable to start job {}: {}".format( cmd, name ) ) - elif not all( [ b > 0 for b in bufs ] ): + elif not all( b > 0 for b in bufs ): raise RuntimeError( "Unable to get all streams for job {}: {}".format( name, cmd ) ) - UserMessage( 'Bufs: {}'.format( [ int(b) for b in bufs ] ), persist = True ) + UserMessage( 'Bufs: {}'.format( [ int( b ) for b in bufs ] ), persist = True ) return [ vim.buffers[ b ] for b in bufs ] @@ -257,11 +257,11 @@ def AppendToBuffer( buf, line_or_lines, modified=False ): buf.append( line_or_lines ) elif isinstance( line_or_lines, str ): line = 1 - buf[-1] = line_or_lines + buf[ -1 ] = line_or_lines else: line = 1 - buf[:] = line_or_lines - except: + buf[ : ] = line_or_lines + except Exception: # There seem to be a lot of Vim bugs that lead to E315, whose help says that # this is an internal error. Ignore the error, but write a trace to the log. logging.getLogger( __name__ ).exception( @@ -276,7 +276,7 @@ def AppendToBuffer( buf, line_or_lines, modified=False ): def ClearBuffer( buf ): - buf[:] = None + buf[ : ] = None def IsCurrent( window, buf ): @@ -330,7 +330,7 @@ def ExpandReferencesInDict( obj, mapping, **kwargs ): def ParseVariables( variables ): new_variables = {} - for n,v in variables.items(): + for n, v in variables.items(): if isinstance( v, dict ): if 'shell' in v: import subprocess diff --git a/python3/vimspector/variables.py b/python3/vimspector/variables.py index a66bf57..7e2c9c9 100644 --- a/python3/vimspector/variables.py +++ b/python3/vimspector/variables.py @@ -93,7 +93,7 @@ class VariablesView( object ): utils.ClearBuffer( self._watch.win.buffer ) def ConnectionUp( self, connection ): - self._connection = connection + self._connection = connection def ConnectionClosed( self ): self.Clear()