Fix style/lint issues

This commit is contained in:
dhleong 2016-10-10 18:51:18 -04:00
parent d274dcd37a
commit f15f9f2255
3 changed files with 24 additions and 20 deletions

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013 Google Inc.
# Copyright (C) 2016 YouCompleteMe contributors
#
# This file is part of YouCompleteMe.
#
@ -23,11 +23,7 @@ from future import standard_library
standard_library.install_aliases()
from builtins import * # noqa
from future.utils import itervalues, iteritems
from collections import defaultdict, namedtuple
from ycm import vimsupport
import re
import vim
class DiagnosticFilter( object ):
@ -35,7 +31,7 @@ class DiagnosticFilter( object ):
self._filters = []
for filter_type in config.iterkeys():
wrapper = lambda x: x
wrapper = _AsIs
actual_filter_type = filter_type
if filter_type[0] == '!':
@ -70,12 +66,16 @@ class DiagnosticFilter( object ):
def _ListOf( config_entry ):
if type( config_entry ) == type( [] ):
if isinstance( config_entry, list ):
return config_entry
return [ config_entry ]
def _AsIs( fn ):
return fn
def _Not( fn ):
def Inverted( diagnostic ):
return not fn( diagnostic )

View File

@ -66,8 +66,11 @@ class DiagnosticInterface( object ):
def UpdateWithNewDiagnostics( self, diags ):
diag_filter = DiagnosticFilter.from_filetype( self._user_options, vimsupport.CurrentFiletypes() )
normalized_diags = [ _NormalizeDiagnostic( x ) for x in diags if diag_filter.Accept(x) ]
diag_filter = DiagnosticFilter.from_filetype(
self._user_options,
vimsupport.CurrentFiletypes() )
normalized_diags = [ _NormalizeDiagnostic( x ) for x in diags
if diag_filter.Accept(x) ]
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict(
normalized_diags )

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013 Google Inc.
# Copyright (C) 2016 YouCompleteMe contributors
#
# This file is part of YouCompleteMe.
#
@ -26,20 +26,21 @@ from builtins import * # noqa
from ycm.test_utils import MockVimModule
MockVimModule()
import os
from hamcrest import assert_that, equal_to
from ycm.diagnostic_filter import DiagnosticFilter
def _assert_accept_equals( filter, text_or_obj, expected ):
if type( text_or_obj ) is not type( {} ):
if not isinstance( text_or_obj, dict ):
text_or_obj = { 'text': text_or_obj }
assert_that( filter.Accept( text_or_obj ), equal_to( expected ) )
def _assert_accepts( filter, text ):
_assert_accept_equals( filter, text, True )
def _assert_rejects( filter, text ):
_assert_accept_equals( filter, text, False )