From 29231e839d17b1f993e70d92b38e19b1c5a11809 Mon Sep 17 00:00:00 2001 From: micbou Date: Thu, 3 May 2018 13:11:19 +0200 Subject: [PATCH] Fix issues reported by flake8-comprehensions --- python/test_requirements.txt | 15 ++++++++------- python/ycm/buffer.py | 10 ++++------ python/ycm/client/completion_request.py | 2 +- python/ycm/syntax_parse.py | 8 ++++---- python/ycm/vimsupport.py | 2 +- python/ycm/youcompleteme.py | 10 +++++----- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/python/test_requirements.txt b/python/test_requirements.txt index 82d6b670..9cc2eef4 100644 --- a/python/test_requirements.txt +++ b/python/test_requirements.txt @@ -1,12 +1,13 @@ -flake8 >= 3.0.0 -mock >= 1.0.1 -nose >= 1.3.7 -PyHamcrest >= 1.8.0 +flake8 >= 3.0.0 +flake8-comprehensions >= 1.4.1 +mock >= 1.0.1 +nose >= 1.3.7 +PyHamcrest >= 1.8.0 # This needs to be kept in sync with submodule checkout in # third_party/ycmd/third_party -future == 0.15.2 +future == 0.15.2 # coverage.py 4.4 removed the path from the filename attribute in its reports. # This leads to incorrect coverage from codecov as it relies on this attribute # to find the source file. -coverage < 4.4 -codecov >= 2.0.5 +coverage < 4.4 +codecov >= 2.0.5 diff --git a/python/ycm/buffer.py b/python/ycm/buffer.py index 9d1266b6..967a6e31 100644 --- a/python/ycm/buffer.py +++ b/python/ycm/buffer.py @@ -27,9 +27,8 @@ from ycm.client.event_notification import EventNotification from ycm.diagnostic_interface import DiagnosticInterface -DIAGNOSTIC_UI_FILETYPES = set( [ 'cpp', 'cs', 'c', 'objc', 'objcpp', - 'typescript' ] ) -DIAGNOSTIC_UI_ASYNC_FILETYPES = set( [ 'java' ] ) +DIAGNOSTIC_UI_FILETYPES = { 'cpp', 'cs', 'c', 'objc', 'objcpp', 'typescript' } +DIAGNOSTIC_UI_ASYNC_FILETYPES = { 'java' } # Emulates Vim buffer @@ -131,8 +130,7 @@ class BufferDict( dict ): new_value = self[ key ] = Buffer( key, self._user_options, - any( [ x in DIAGNOSTIC_UI_ASYNC_FILETYPES - for x in - vimsupport.GetBufferFiletypes( key ) ] ) ) + any( x in DIAGNOSTIC_UI_ASYNC_FILETYPES + for x in vimsupport.GetBufferFiletypes( key ) ) ) return new_value diff --git a/python/ycm/client/completion_request.py b/python/ycm/client/completion_request.py index 18469ade..c55c72d4 100644 --- a/python/ycm/client/completion_request.py +++ b/python/ycm/client/completion_request.py @@ -181,7 +181,7 @@ def _FilterToMatchingCompletions( completed_item, completions ): return ( ToUnicode( completed_item.get( key, "" ) ) == ToUnicode( item.get( key, "" ) ) ) - if all( [ matcher( i ) for i in match_keys ] ): + if all( matcher( i ) for i in match_keys ): matched_completions.append( completion ) return matched_completions diff --git a/python/ycm/syntax_parse.py b/python/ycm/syntax_parse.py index 2014aa72..375cf244 100644 --- a/python/ycm/syntax_parse.py +++ b/python/ycm/syntax_parse.py @@ -45,20 +45,20 @@ SYNTAX_REGION_ARGUMENT_REGEX = re.compile( r"^(?:matchgroup|start)=.*$") # See ":h syn-nextgroup". -SYNTAX_NEXTGROUP_ARGUMENTS = set([ +SYNTAX_NEXTGROUP_ARGUMENTS = { 'skipwhite', 'skipnl', 'skipempty' -]) +} # These are the parent groups from which we want to extract keywords. -ROOT_GROUPS = set([ +ROOT_GROUPS = { 'Boolean', 'Identifier', 'Statement', 'PreProc', 'Type' -]) +} class SyntaxGroup( object ): diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index b974da06..76a725f6 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -670,7 +670,7 @@ def CurrentFiletypesEnabled( disabled_filetypes ): filetypes and values are unimportant. The special key '*' matches all filetypes.""" return ( '*' not in disabled_filetypes and - not any( [ x in disabled_filetypes for x in CurrentFiletypes() ] ) ) + not any( x in disabled_filetypes for x in CurrentFiletypes() ) ) def GetBufferFiletypes( bufnr ): diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index da5e356e..a4a7a9d8 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -357,8 +357,8 @@ class YouCompleteMe( object ): def NativeFiletypeCompletionAvailable( self ): - return any( [ self.FiletypeCompleterExistsForFiletype( x ) for x in - vimsupport.CurrentFiletypes() ] ) + return any( self.FiletypeCompleterExistsForFiletype( x ) for x in + vimsupport.CurrentFiletypes() ) def NativeFiletypeCompletionUsable( self ): @@ -498,9 +498,9 @@ class YouCompleteMe( object ): def DiagnosticUiSupportedForCurrentFiletype( self ): - return any( [ x in DIAGNOSTIC_UI_FILETYPES or - x in DIAGNOSTIC_UI_ASYNC_FILETYPES - for x in vimsupport.CurrentFiletypes() ] ) + return any( x in DIAGNOSTIC_UI_FILETYPES or + x in DIAGNOSTIC_UI_ASYNC_FILETYPES + for x in vimsupport.CurrentFiletypes() ) def ShouldDisplayDiagnostics( self ):