Skip to content

Commit

Permalink
Merge pull request #1455 from bstaletic/no-py35
Browse files Browse the repository at this point in the history
[READY] Drop python 3.5 support
  • Loading branch information
mergify[bot] authored Jul 21, 2020
2 parents c3581c3 + b437de9 commit 5011f68
Show file tree
Hide file tree
Showing 46 changed files with 152 additions and 174 deletions.
6 changes: 3 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
IS_64BIT = sys.maxsize > 2**32
PY_MAJOR, PY_MINOR = sys.version_info[ 0 : 2 ]
PY_VERSION = sys.version_info[ 0 : 3 ]
if PY_VERSION < ( 3, 5, 1 ):
sys.exit( 'ycmd requires Python >= 3.5.1; '
if PY_VERSION < ( 3, 6, 0 ):
sys.exit( 'ycmd requires Python >= 3.6.0; '
'your version of Python is ' + sys.version +
'\nHint: Try running python3 ' + ' '.join( sys.argv ) )

Expand Down Expand Up @@ -62,7 +62,7 @@
# Regular expressions used to find static and dynamic Python libraries.
# Notes:
# - Python 3 library name may have an 'm' suffix on Unix platforms, for
# instance libpython3.5m.so;
# instance libpython3.6m.so;
# - the linker name (the soname without the version) does not always
# exist so we look for the versioned names too;
# - on Windows, the .lib extension is used instead of the .dll one. See
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ycmd example client

The example client **requires** Python 3.5+.
The example client **requires** Python 3.6+.

First make sure you have built ycmd; see the top-level README for details.

Expand Down
13 changes: 6 additions & 7 deletions examples/example_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys
import platform
if sys.version_info[ 0 ] < 3:
sys.exit( 'example_client.py requires Python 3.5+; detected Python ' +
sys.exit( 'example_client.py requires Python 3.6+; detected Python ' +
platform.python_version() )

from base64 import b64encode, b64decode
Expand Down Expand Up @@ -85,10 +85,9 @@ def StartYcmdAndReturnHandle( cls ):
server_port = GetUnusedLocalhostPort()
ycmd_args = [ sys.executable,
PATH_TO_YCMD,
'--port={0}'.format( server_port ),
'--options_file={0}'.format( options_file.name ),
'--idle_suicide_seconds={0}'.format(
SERVER_IDLE_SUICIDE_SECONDS ) ]
f'--port={server_port}',
f'--options_file={options_file.name}',
f'--idle_suicide_seconds={SERVER_IDLE_SUICIDE_SECONDS}' ]

std_handles = None if INCLUDE_YCMD_OUTPUT else subprocess.PIPE
child_handle = subprocess.Popen( ycmd_args,
Expand Down Expand Up @@ -207,8 +206,8 @@ def WaitUntilReady( self, filetype = None ):
try:
if total_slept > MAX_SERVER_WAIT_TIME_SECONDS:
raise RuntimeError(
'waited for the server for {0} seconds, aborting'.format(
MAX_SERVER_WAIT_TIME_SECONDS ) )
'waited for the server for '
f'{MAX_SERVER_WAIT_TIME_SECONDS} seconds, aborting' )

if self.IsReady( filetype ):
return
Expand Down
2 changes: 1 addition & 1 deletion update_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def GenerateNormalizationTestCases( output_file ):
test_contents = Download(
'https://unicode.org/Public/UCD/latest/ucd/NormalizationTest.txt' )
hex_codepoint = '(?:[A-F0-9]{4,} ?)+'
pattern = f'(?:{hex_codepoint};){{5}}'
pattern = f'(?:{ hex_codepoint };){{5}}'
pattern = re.compile( pattern )

res = []
Expand Down
2 changes: 1 addition & 1 deletion ycmd/completers/cpp/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def _MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
path = AbsolutePath( path, working_directory )
new_flag = '{0}{1}'.format( path_flag, path )
new_flag = f'{ path_flag }{ path }'
break

if new_flag:
Expand Down
8 changes: 4 additions & 4 deletions ycmd/completers/cs/solutiondetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ def _SolutionTestCheckHeuristics( candidates, tokens, i ):
# there is more than one file, try some hints to decide
# 1. is there a solution named just like the subdirectory with the source?
if ( not selection and i < len( tokens ) - 1 and
'{0}.sln'.format( tokens[ i + 1 ] ) in candidates ):
selection = os.path.join( path, '{0}.sln'.format( tokens[ i + 1 ] ) )
f'{ tokens[ i + 1 ] }.sln' in candidates ):
selection = os.path.join( path, f'{ tokens[ i + 1] }.sln' )
LOGGER.info( 'Selected solution file %s as it matches source subfolder',
selection )

# 2. is there a solution named just like the directory containing the
# solution?
if not selection and '{0}.sln'.format( tokens[ i ] ) in candidates :
selection = os.path.join( path, '{0}.sln'.format( tokens[ i ] ) )
if not selection and f'{ tokens[ i ] }.sln' in candidates :
selection = os.path.join( path, f'{ tokens[ i ] }.sln' )
LOGGER.info( 'Selected solution file %s as it matches containing folder',
selection )

Expand Down
22 changes: 9 additions & 13 deletions ycmd/completers/java/java_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,34 +142,32 @@ def _CollectExtensionBundles( extension_path ):

for extension_dir in extension_path:
if not os.path.isdir( extension_dir ):
LOGGER.info( 'extension directory does not exist: {0}'.format(
extension_dir ) )
LOGGER.info( f'extension directory does not exist: { extension_dir }' )
continue

for path in os.listdir( extension_dir ):
path = os.path.join( extension_dir, path )
manifest_file = os.path.join( path, 'package.json' )

if not os.path.isdir( path ) or not os.path.isfile( manifest_file ):
LOGGER.debug( '{0} is not an extension directory'.format( path ) )
LOGGER.debug( f'{ path } is not an extension directory' )
continue

manifest_json = utils.ReadFile( manifest_file )
try:
manifest = json.loads( manifest_json )
except ValueError:
LOGGER.exception( 'Could not load bundle {0}'.format( manifest_file ) )
LOGGER.exception( f'Could not load bundle { manifest_file }' )
continue

if ( 'contributes' not in manifest or
'javaExtensions' not in manifest[ 'contributes' ] or
not isinstance( manifest[ 'contributes' ][ 'javaExtensions' ],
list ) ):
LOGGER.info( 'Bundle {0} is not a java extension'.format(
manifest_file ) )
LOGGER.info( f'Bundle { manifest_file } is not a java extension' )
continue

LOGGER.info( 'Found bundle: {0}'.format( manifest_file ) )
LOGGER.info( f'Found bundle: { manifest_file }' )

extension_bundles.extend( [
os.path.join( path, p )
Expand Down Expand Up @@ -293,8 +291,7 @@ def __init__( self, user_options ):
self._workspace_root_path = DEFAULT_WORKSPACE_ROOT_PATH

if not isinstance( self._extension_path, list ):
raise ValueError( '{0} option must be a list'.format(
EXTENSION_PATH_OPTION ) )
raise ValueError( f'{ EXTENSION_PATH_OPTION } option must be a list' )

if not self._extension_path:
self._extension_path = [ DEFAULT_EXTENSION_PATH ]
Expand Down Expand Up @@ -452,8 +449,7 @@ def StartServer( self,

if not self._use_clean_workspace and wipe_workspace:
if os.path.isdir( self._workspace_path ):
LOGGER.info( 'Wiping out workspace {0}'.format(
self._workspace_path ) )
LOGGER.info( f'Wiping out workspace { self._workspace_path }' )
shutil.rmtree( self._workspace_path )

self._launcher_config = _LauncherConfiguration(
Expand Down Expand Up @@ -519,11 +515,11 @@ def ConvertNotificationToMessage( self, request_data, notification ):
if notification[ 'params' ][ 'type' ] == 'Started':
self._started_message_sent = True
return responses.BuildDisplayMessageResponse(
'Initializing Java completer: {}'.format( message ) )
f'Initializing Java completer: { message }' )

if not self._started_message_sent:
return responses.BuildDisplayMessageResponse(
'Initializing Java completer: {}'.format( message ) )
f'Initializing Java completer: { message }' )

return super().ConvertNotificationToMessage( request_data, notification )

Expand Down
20 changes: 11 additions & 9 deletions ycmd/completers/language_server/language_server_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@ def AwaitResponse( self, timeout ):

if 'error' in self._message:
error = self._message[ 'error' ]
raise ResponseFailedException( 'Request failed: {0}: {1}'.format(
error.get( 'code' ) or 0,
error.get( 'message' ) or 'No message' ) )
raise ResponseFailedException(
'Request failed: '
f'{ error.get( "code" ) or 0 }'
': '
f'{ error.get( "message" ) or "No message" }' )

return self._message

Expand Down Expand Up @@ -909,8 +911,8 @@ def _StartServerNoLock( self, request_data ):
self.GetServerName(),
self.GetCommandLine() )

self._stderr_file = utils.CreateLogfile( '{}_stderr'.format(
utils.MakeSafeFileNameString( self.GetServerName() ) ) )
self._stderr_file = utils.CreateLogfile(
f'{ utils.MakeSafeFileNameString( self.GetServerName() ) }_stderr' )

with utils.OpenForStdHandle( self._stderr_file ) as stderr:
self._server_handle = utils.SafePopen(
Expand Down Expand Up @@ -2714,9 +2716,9 @@ def _GetCompletionItemStartCodepointOrReject( text_edit, request_data ):

# Conservatively rejecting candidates that breach the protocol
if edit_range[ 'start' ][ 'line' ] != edit_range[ 'end' ][ 'line' ]:
new_text = text_edit[ 'newText' ]
raise IncompatibleCompletionException(
"The TextEdit '{0}' spans multiple lines".format(
text_edit[ 'newText' ] ) )
f"The TextEdit '{ new_text }' spans multiple lines" )

file_contents = GetFileLines( request_data, request_data[ 'filepath' ] )
line_value = file_contents[ edit_range[ 'start' ][ 'line' ] ]
Expand All @@ -2726,9 +2728,9 @@ def _GetCompletionItemStartCodepointOrReject( text_edit, request_data ):
edit_range[ 'start' ][ 'character' ] + 1 )

if start_codepoint > request_data[ 'start_codepoint' ]:
new_text = text_edit[ 'newText' ]
raise IncompatibleCompletionException(
"The TextEdit '{0}' starts after the start position".format(
text_edit[ 'newText' ] ) )
f"The TextEdit '{ new_text }' starts after the start position" )

return start_codepoint

Expand Down
3 changes: 1 addition & 2 deletions ycmd/completers/language_server/language_server_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,7 @@ def _BuildMessageData( message ):
data = ToBytes( json.dumps( message,
separators = ( ',', ':' ),
sort_keys=True ) )
packet = ToBytes( 'Content-Length: {0}\r\n'
'\r\n'.format( len( data ) ) ) + data
packet = ToBytes( f'Content-Length: { len( data ) }\r\n\r\n' ) + data
return packet


Expand Down
4 changes: 2 additions & 2 deletions ycmd/completers/python/python_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def _EnvironmentForInterpreterPath( self, interpreter_path ):
resolved_interpreter_path = FindExecutable(
ExpandVariablesInPath( interpreter_path ) )
if not resolved_interpreter_path:
raise RuntimeError( 'Cannot find Python interpreter path {}.'.format(
interpreter_path ) )
raise RuntimeError( 'Cannot find Python interpreter path '
f'{ interpreter_path }.' )
interpreter_path = os.path.normpath( resolved_interpreter_path )

try:
Expand Down
2 changes: 1 addition & 1 deletion ycmd/completers/rust/rust_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def ConvertNotificationToMessage( self, request_data, notification ):
message = notification[ 'params' ]
if message != 'invalid': # RA produces a better message for `invalid`
return responses.BuildDisplayMessageResponse(
'Initializing Rust completer: {}'.format( message ) )
f'Initializing Rust completer: { message }' )
return super().ConvertNotificationToMessage( request_data, notification )


Expand Down
10 changes: 4 additions & 6 deletions ycmd/completers/typescript/typescript_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ def _StartServerNoLock( self ):
return

self._logfile = utils.CreateLogfile( LOGFILE_FORMAT )
tsserver_log = '-file {path} -level {level}'.format( path = self._logfile,
level = _LogLevel() )
tsserver_log = f'-file { self._logfile } -level {_LogLevel()}'
# TSServer gets the configuration for the log file through the
# environment variable 'TSS_LOG'. This seems to be undocumented but
# looking at the source code it seems like this is the way:
Expand Down Expand Up @@ -794,8 +793,7 @@ def _GetDoc( self, request_data ):
'offset': request_data[ 'column_codepoint' ]
} )

message = '{0}\n\n{1}'.format( info[ 'displayString' ],
info[ 'documentation' ] )
message = f'{ info[ "displayString" ] }\n\n{info[ "documentation" ]}'
return responses.BuildDetailedInfoResponse( message )


Expand Down Expand Up @@ -854,8 +852,8 @@ def _RefactorRename( self, request_data, args ):
} )

if not response[ 'info' ][ 'canRename' ]:
raise RuntimeError( 'Value cannot be renamed: {0}'.format(
response[ 'info' ][ 'localizedErrorMessage' ] ) )
raise RuntimeError( 'Value cannot be renamed: '
f'{ response[ "info" ][ "localizedErrorMessage" ] }' )

# The format of the response is:
#
Expand Down
11 changes: 6 additions & 5 deletions ycmd/request_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ def EnsureRequestValid( request_json ):


def _FieldMissingMessage( field ):
return 'Request missing required field: {0}'.format( field )
return f'Request missing required field: { field }'


def _FilepathInFileDataSpec( request_json ):
return 'file_data["{0}"]'.format( request_json[ 'filepath' ] )
filepath = request_json[ 'filepath' ]
return f'file_data[ "{ filepath }" ]'


def _SingleFileDataFieldSpec( request_json, field ):
return '{0}["{1}"]'.format( _FilepathInFileDataSpec( request_json ), field )
return f'{ _FilepathInFileDataSpec( request_json ) }[ "{ field }" ]'


def _MissingFieldsForFileData( request_json ):
Expand All @@ -55,8 +56,8 @@ def _MissingFieldsForFileData( request_json ):
missing.add( _SingleFileDataFieldSpec( request_json, required ) )
filetypes = data_for_file.get( 'filetypes', [] )
if not filetypes:
missing.add( '{0}[0]'.format(
_SingleFileDataFieldSpec( request_json, 'filetypes' ) ) )
missing.add(
f'{ _SingleFileDataFieldSpec( request_json, "filetypes" ) }[ 0 ]' )
else:
missing.add( _FilepathInFileDataSpec( request_json ) )
return missing
2 changes: 1 addition & 1 deletion ycmd/request_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __setitem__( self, key, value ):
setter( value )
return

raise ValueError( 'Key "{0}" is read-only'.format( key ) )
raise ValueError( f'Key "{ key }" is read-only' )


def __contains__( self, key ):
Expand Down
6 changes: 3 additions & 3 deletions ycmd/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
CONFIRM_CONF_FILE_MESSAGE = ( 'Found {0}. Load? \n\n(Question can be turned '
'off with options, see YCM docs)' )

NO_EXTRA_CONF_FILENAME_MESSAGE = ( 'No {0} file detected, so no compile flags '
'are available. Thus no semantic support for C/C++/ObjC/ObjC++. Go READ THE '
'DOCS *NOW*, DON\'T file a bug report.' ).format( YCM_EXTRA_CONF_FILENAME )
NO_EXTRA_CONF_FILENAME_MESSAGE = ( f'No { YCM_EXTRA_CONF_FILENAME } file '
'detected, so no compile flags are available. Thus no semantic support for '
'C/C++/ObjC/ObjC++. Go READ THE ' 'DOCS *NOW*, DON\'T file a bug report.' )

NO_DIAGNOSTIC_SUPPORT_MESSAGE = ( 'YCM has no diagnostics support for this '
'filetype; refer to Syntastic docs if using Syntastic.' )
Expand Down
6 changes: 3 additions & 3 deletions ycmd/server_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _GetFiletypeCompleterForFiletype( self, filetype ):
pass

try:
module = import_module( 'ycmd.completers.{}.hook'.format( filetype ) )
module = import_module( f'ycmd.completers.{ filetype }.hook' )
completer = module.GetCompleter( self._user_options )
except ImportError:
completer = None
Expand All @@ -88,8 +88,8 @@ def GetFiletypeCompleter( self, current_filetypes ):
if completer:
return completer

raise ValueError( 'No semantic completer exists for filetypes: {0}'.format(
current_filetypes ) )
raise ValueError(
f'No semantic completer exists for filetypes: { current_filetypes }' )


def GetLoadedFiletypeCompleters( self ):
Expand Down
2 changes: 1 addition & 1 deletion ycmd/tests/clang/flags_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ def CompilationDatabase_CUDALanguageFlags_test():
compile_commands = [
{
'directory': tmp_dir,
'command': 'clang++ -Wall {}'.format( './test.cu' ),
'command': 'clang++ -Wall ./test.cu',
'file': os.path.join( tmp_dir, 'test.cu' ),
},
]
Expand Down
3 changes: 1 addition & 2 deletions ycmd/tests/clang/get_completions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def RunTest( app, test ):
assert_that( response.status_code,
equal_to( test[ 'expect' ][ 'response' ] ) )

print( 'Completer response: {0}'.format( json.dumps(
response.json, indent = 2 ) ) )
print( f'Completer response: { json.dumps( response.json, indent = 2 ) }' )

assert_that( response.json, test[ 'expect' ][ 'data' ] )

Expand Down
3 changes: 1 addition & 2 deletions ycmd/tests/clangd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def RunAfterInitialized( app, test ):
expect_errors = expect_errors )

if 'expect' in test:
print( "Completer response: {}".format( json.dumps( response.json,
indent = 2 ) ) )
print( f'Completer response: { json.dumps( response.json, indent = 2 ) }' )
assert_that( response.status_code,
equal_to( test[ 'expect' ][ 'response' ] ) )
assert_that( response.json, test[ 'expect' ][ 'data' ] )
Expand Down
2 changes: 1 addition & 1 deletion ycmd/tests/clangd/diagnostics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def Diagnostics_UpdatedOnBufferVisit_test( app ):

# Assert no diagnostics
for message in PollForMessages( app, messages_request ):
print( 'Message {}'.format( pformat( message ) ) )
print( f'Message { pformat( message ) }' )
if 'diagnostics' in message:
assert_that( message,
has_entries( { 'diagnostics': empty() } ) )
Expand Down
Loading

0 comments on commit 5011f68

Please sign in to comment.