Fix Flake8 errors
Fix invalid escape sequences in string literals. Ignore E301 and W504.
This commit is contained in:
parent
34dee0ebcb
commit
88bdfc01f9
@ -37,30 +37,30 @@ import sys
|
||||
from ycmd.utils import GetCurrentDirectory, ToBytes, ToUnicode
|
||||
|
||||
|
||||
BUFNR_REGEX = re.compile( '^bufnr\(\'(?P<buffer_filename>.+)\', ([01])\)$' )
|
||||
BUFWINNR_REGEX = re.compile( '^bufwinnr\((?P<buffer_number>[0-9]+)\)$' )
|
||||
BUFNR_REGEX = re.compile( '^bufnr\\(\'(?P<buffer_filename>.+)\', ([01])\\)$' )
|
||||
BUFWINNR_REGEX = re.compile( '^bufwinnr\\((?P<buffer_number>[0-9]+)\\)$' )
|
||||
BWIPEOUT_REGEX = re.compile(
|
||||
'^(?:silent! )bwipeout!? (?P<buffer_number>[0-9]+)$' )
|
||||
GETBUFVAR_REGEX = re.compile(
|
||||
'^getbufvar\((?P<buffer_number>[0-9]+), "(?P<option>.+)"\)$' )
|
||||
'^getbufvar\\((?P<buffer_number>[0-9]+), "(?P<option>.+)"\\)$' )
|
||||
MATCHADD_REGEX = re.compile(
|
||||
'^matchadd\(\'(?P<group>.+)\', \'(?P<pattern>.+)\'\)$' )
|
||||
MATCHDELETE_REGEX = re.compile( '^matchdelete\((?P<id>\d+)\)$' )
|
||||
'^matchadd\\(\'(?P<group>.+)\', \'(?P<pattern>.+)\'\\)$' )
|
||||
MATCHDELETE_REGEX = re.compile( '^matchdelete\\((?P<id>\\d+)\\)$' )
|
||||
OMNIFUNC_REGEX_FORMAT = (
|
||||
'^{omnifunc_name}\((?P<findstart>[01]),[\'"](?P<base>.*)[\'"]\)$' )
|
||||
FNAMEESCAPE_REGEX = re.compile( '^fnameescape\(\'(?P<filepath>.+)\'\)$' )
|
||||
'^{omnifunc_name}\\((?P<findstart>[01]),[\'"](?P<base>.*)[\'"]\\)$' )
|
||||
FNAMEESCAPE_REGEX = re.compile( '^fnameescape\\(\'(?P<filepath>.+)\'\\)$' )
|
||||
SIGN_LIST_REGEX = re.compile(
|
||||
"^silent! sign place buffer=(?P<bufnr>\d+)$" )
|
||||
'^silent! sign place buffer=(?P<bufnr>\\d+)$' )
|
||||
SIGN_PLACE_REGEX = re.compile(
|
||||
'^sign place (?P<id>\d+) name=(?P<name>\w+) line=(?P<line>\d+) '
|
||||
'buffer=(?P<bufnr>\d+)$' )
|
||||
'^sign place (?P<id>\\d+) name=(?P<name>\\w+) line=(?P<line>\\d+) '
|
||||
'buffer=(?P<bufnr>\\d+)$' )
|
||||
SIGN_UNPLACE_REGEX = re.compile(
|
||||
'^sign unplace (?P<id>\d+) buffer=(?P<bufnr>\d+)$' )
|
||||
REDIR_START_REGEX = re.compile( '^redir => (?P<variable>[\w:]+)$' )
|
||||
'^sign unplace (?P<id>\\d+) buffer=(?P<bufnr>\\d+)$' )
|
||||
REDIR_START_REGEX = re.compile( '^redir => (?P<variable>[\\w:]+)$' )
|
||||
REDIR_END_REGEX = re.compile( '^redir END$' )
|
||||
EXISTS_REGEX = re.compile( '^exists\( \'(?P<option>[\w:]+)\' \)$' )
|
||||
LET_REGEX = re.compile( '^let (?P<option>[\w:]+) = (?P<value>.*)$' )
|
||||
HAS_PATCH_REGEX = re.compile( '^has\( \'patch(?P<patch>\d+)\' \)$' )
|
||||
EXISTS_REGEX = re.compile( '^exists\\( \'(?P<option>[\\w:]+)\' \\)$' )
|
||||
LET_REGEX = re.compile( '^let (?P<option>[\\w:]+) = (?P<value>.*)$' )
|
||||
HAS_PATCH_REGEX = re.compile( '^has\\( \'patch(?P<patch>\\d+)\' \\)$' )
|
||||
|
||||
# One-and only instance of mocked Vim object. The first 'import vim' that is
|
||||
# executed binds the vim module to the instance of MagicMock that is created,
|
||||
|
@ -1339,7 +1339,7 @@ def GetDiagnosticMatchPattern_ErrorInMiddleOfLine_test():
|
||||
with patch( 'vim.current.buffer', current_buffer ):
|
||||
assert_that(
|
||||
vimsupport.GetDiagnosticMatchPattern( 1, 16, 1, 21 ),
|
||||
equal_to( '\%1l\%16c\_.\{-}\%1l\%21c' )
|
||||
equal_to( '\\%1l\\%16c\\_.\\{-}\\%1l\\%21c' )
|
||||
)
|
||||
|
||||
|
||||
@ -1352,7 +1352,7 @@ def AddDiagnosticSyntaxMatch_WarningAtEndOfLine_test():
|
||||
with patch( 'vim.current.buffer', current_buffer ):
|
||||
assert_that(
|
||||
vimsupport.GetDiagnosticMatchPattern( 1, 16, 1, 23 ),
|
||||
equal_to( '\%1l\%16c\_.\{-}\%1l\%23c' )
|
||||
equal_to( '\\%1l\\%16c\\_.\\{-}\\%1l\\%23c' )
|
||||
)
|
||||
|
||||
|
||||
@ -1365,7 +1365,7 @@ def AddDiagnosticSyntaxMatch_UnicodeAtEndOfLine_test():
|
||||
with patch( 'vim.current.buffer', current_buffer ):
|
||||
assert_that(
|
||||
vimsupport.GetDiagnosticMatchPattern( 1, 16, 1, 19 ),
|
||||
equal_to( '\%1l\%16c\_.\{-}\%1l\%19c' )
|
||||
equal_to( '\\%1l\\%16c\\_.\\{-}\\%1l\\%19c' )
|
||||
)
|
||||
|
||||
|
||||
|
@ -126,9 +126,10 @@ def RunNotifyUserIfServerCrashed( ycm, test, post_vim_message ):
|
||||
|
||||
|
||||
def YouCompleteMe_NotifyUserIfServerCrashed_UnexpectedCore_test():
|
||||
message = ( "The ycmd server SHUT DOWN \(restart with ':YcmRestartServer'\). "
|
||||
"Unexpected error while loading the YCM core library. Type "
|
||||
"':YcmToggleLogs ycmd_\d+_stderr_.+.log' to check the logs." )
|
||||
message = (
|
||||
"The ycmd server SHUT DOWN \\(restart with ':YcmRestartServer'\\). "
|
||||
"Unexpected error while loading the YCM core library. Type "
|
||||
"':YcmToggleLogs ycmd_\\d+_stderr_.+.log' to check the logs." )
|
||||
RunNotifyUserIfServerCrashed( {
|
||||
'return_code': 3,
|
||||
'expected_message': matches_regexp( message )
|
||||
@ -178,9 +179,10 @@ def YouCompleteMe_NotifyUserIfServerCrashed_OutdatedCore_test():
|
||||
|
||||
|
||||
def YouCompleteMe_NotifyUserIfServerCrashed_UnexpectedExitCode_test():
|
||||
message = ( "The ycmd server SHUT DOWN \(restart with ':YcmRestartServer'\). "
|
||||
"Unexpected exit code 1. Type "
|
||||
"':YcmToggleLogs ycmd_\d+_stderr_.+.log' to check the logs." )
|
||||
message = (
|
||||
"The ycmd server SHUT DOWN \\(restart with ':YcmRestartServer'\\). "
|
||||
"Unexpected exit code 1. Type "
|
||||
"':YcmToggleLogs ycmd_\\d+_stderr_.+.log' to check the logs." )
|
||||
RunNotifyUserIfServerCrashed( {
|
||||
'return_code': 1,
|
||||
'expected_message': matches_regexp( message )
|
||||
@ -212,7 +214,7 @@ def YouCompleteMe_DebugInfo_ServerRunning_test( ycm ):
|
||||
' Flags: \\[u?\'_TEMP_FILE_\'.*\\]\n'
|
||||
' Translation unit: .+\n)'
|
||||
'Server running at: .+\n'
|
||||
'Server process ID: \d+\n'
|
||||
'Server process ID: \\d+\n'
|
||||
'Server logfiles:\n'
|
||||
' .+\n'
|
||||
' .+' )
|
||||
@ -231,7 +233,7 @@ def YouCompleteMe_DebugInfo_ServerNotRunning_test( ycm ):
|
||||
'Client logfile: .+\n'
|
||||
'Server errored, no debug info from server\n'
|
||||
'Server running at: .+\n'
|
||||
'Server process ID: \d+\n'
|
||||
'Server process ID: \\d+\n'
|
||||
'Server logfiles:\n'
|
||||
' .+\n'
|
||||
' .+' )
|
||||
@ -626,9 +628,9 @@ def YouCompleteMe_UpdateDiagnosticInterface_PrioritizeErrorsOverWarnings_test(
|
||||
test_utils.VIM_MATCHES_FOR_WINDOW,
|
||||
has_entries( {
|
||||
1: contains(
|
||||
VimMatch( 'YcmWarningSection', '\%3l\%5c\_.\{-}\%3l\%7c' ),
|
||||
VimMatch( 'YcmWarningSection', '\%3l\%3c\_.\{-}\%3l\%9c' ),
|
||||
VimMatch( 'YcmErrorSection', '\%3l\%8c' )
|
||||
VimMatch( 'YcmWarningSection', '\\%3l\\%5c\\_.\\{-}\\%3l\\%7c' ),
|
||||
VimMatch( 'YcmWarningSection', '\\%3l\\%3c\\_.\\{-}\\%3l\\%9c' ),
|
||||
VimMatch( 'YcmErrorSection', '\\%3l\\%8c' )
|
||||
)
|
||||
} )
|
||||
)
|
||||
@ -670,8 +672,8 @@ def YouCompleteMe_UpdateDiagnosticInterface_PrioritizeErrorsOverWarnings_test(
|
||||
test_utils.VIM_MATCHES_FOR_WINDOW,
|
||||
has_entries( {
|
||||
1: contains(
|
||||
VimMatch( 'YcmWarningSection', '\%3l\%5c\_.\{-}\%3l\%7c' ),
|
||||
VimMatch( 'YcmWarningSection', '\%3l\%3c\_.\{-}\%3l\%9c' )
|
||||
VimMatch( 'YcmWarningSection', '\\%3l\\%5c\\_.\\{-}\\%3l\\%7c' ),
|
||||
VimMatch( 'YcmWarningSection', '\\%3l\\%3c\\_.\\{-}\\%3l\\%9c' )
|
||||
)
|
||||
} )
|
||||
)
|
||||
@ -692,9 +694,9 @@ def YouCompleteMe_UpdateMatches_ClearDiagnosticMatchesInNewBuffer_test( ycm ):
|
||||
|
||||
test_utils.VIM_MATCHES_FOR_WINDOW.clear()
|
||||
test_utils.VIM_MATCHES_FOR_WINDOW[ 1 ] = [
|
||||
VimMatch( 'YcmWarningSection', '\%3l\%5c\_.\{-}\%3l\%7c' ),
|
||||
VimMatch( 'YcmWarningSection', '\%3l\%3c\_.\{-}\%3l\%9c' ),
|
||||
VimMatch( 'YcmErrorSection', '\%3l\%8c' )
|
||||
VimMatch( 'YcmWarningSection', '\\%3l\\%5c\\_.\\{-}\\%3l\\%7c' ),
|
||||
VimMatch( 'YcmWarningSection', '\\%3l\\%3c\\_.\\{-}\\%3l\\%9c' ),
|
||||
VimMatch( 'YcmErrorSection', '\\%3l\\%8c' )
|
||||
]
|
||||
|
||||
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
|
||||
@ -862,7 +864,7 @@ def YouCompleteMe_AsyncDiagnosticUpdate_SingleFile_test( ycm,
|
||||
test_utils.VIM_MATCHES_FOR_WINDOW,
|
||||
has_entries( {
|
||||
1: contains(
|
||||
VimMatch( 'YcmErrorSection', '\%1l\%1c\_.\{-}\%1l\%1c' )
|
||||
VimMatch( 'YcmErrorSection', '\\%1l\\%1c\\_.\\{-}\\%1l\\%1c' )
|
||||
)
|
||||
} )
|
||||
)
|
||||
@ -1049,10 +1051,10 @@ def YouCompleteMe_AsyncDiagnosticUpdate_PerFile_test( ycm,
|
||||
test_utils.VIM_MATCHES_FOR_WINDOW,
|
||||
has_entries( {
|
||||
1: contains(
|
||||
VimMatch( 'YcmErrorSection', '\%1l\%1c\_.\{-}\%1l\%1c' )
|
||||
VimMatch( 'YcmErrorSection', '\\%1l\\%1c\\_.\\{-}\\%1l\\%1c' )
|
||||
),
|
||||
3: contains(
|
||||
VimMatch( 'YcmErrorSection', '\%3l\%3c\_.\{-}\%3l\%3c' )
|
||||
VimMatch( 'YcmErrorSection', '\\%3l\\%3c\\_.\\{-}\\%3l\\%3c' )
|
||||
)
|
||||
} )
|
||||
)
|
||||
|
@ -257,16 +257,16 @@ def GetDiagnosticMatchPattern( line_num,
|
||||
line_num, column_num = LineAndColumnNumbersClamped( line_num, column_num )
|
||||
|
||||
if not line_end_num or not column_end_num:
|
||||
return '\%{}l\%{}c'.format( line_num, column_num )
|
||||
return '\\%{}l\\%{}c'.format( line_num, column_num )
|
||||
|
||||
# -1 and then +1 to account for column end not included in the range.
|
||||
line_end_num, column_end_num = LineAndColumnNumbersClamped(
|
||||
line_end_num, column_end_num - 1 )
|
||||
column_end_num += 1
|
||||
return '\%{}l\%{}c\_.\\{{-}}\%{}l\%{}c'.format( line_num,
|
||||
column_num,
|
||||
line_end_num,
|
||||
column_end_num )
|
||||
return '\\%{}l\\%{}c\\_.\\{{-}}\\%{}l\\%{}c'.format( line_num,
|
||||
column_num,
|
||||
line_end_num,
|
||||
column_end_num )
|
||||
|
||||
|
||||
# Clamps the line and column numbers so that they are not past the contents of
|
||||
@ -993,13 +993,13 @@ def InsertNamespace( namespace ):
|
||||
vim.eval( expr )
|
||||
return
|
||||
|
||||
pattern = '^\s*using\(\s\+[a-zA-Z0-9]\+\s\+=\)\?\s\+[a-zA-Z0-9.]\+\s*;\s*'
|
||||
pattern = r'^\s*using\(\s\+[a-zA-Z0-9]\+\s\+=\)\?\s\+[a-zA-Z0-9.]\+\s*;\s*'
|
||||
existing_indent = ''
|
||||
line = SearchInCurrentBuffer( pattern )
|
||||
if line:
|
||||
existing_line = LineTextInCurrentBuffer( line )
|
||||
existing_indent = re.sub( r"\S.*", "", existing_line )
|
||||
new_line = "{0}using {1};\n".format( existing_indent, namespace )
|
||||
existing_indent = re.sub( r'\S.*', '', existing_line )
|
||||
new_line = '{0}using {1};\n'.format( existing_indent, namespace )
|
||||
replace_pos = { 'line_num': line + 1, 'column_num': 1 }
|
||||
ReplaceChunk( replace_pos, replace_pos, new_line, vim.current.buffer )
|
||||
PostVimMessage( 'Add namespace: {0}'.format( namespace ), warning = False )
|
||||
|
2
tox.ini
2
tox.ini
@ -1,4 +1,4 @@
|
||||
[flake8]
|
||||
ignore = E111,E114,E121,E125,E126,E127,E128,E129,E131,E133,E201,E202,E203,E221,E222,E241,E251,E261,E303,E402,W503
|
||||
ignore = E111,E114,E121,E125,E126,E127,E128,E129,E131,E133,E201,E202,E203,E221,E222,E241,E251,E261,E301,E303,E402,W503,W504
|
||||
max-complexity = 10
|
||||
max-line-length = 80
|
||||
|
Loading…
Reference in New Issue
Block a user