@@ -117,18 +117,18 @@ def Exit( self ):
117117
118118def FindLatestMSVC ():
119119 import winreg
120- aReg = winreg .ConnectRegistry (None , winreg .HKEY_LOCAL_MACHINE )
120+ handle = winreg .ConnectRegistry (None , winreg .HKEY_LOCAL_MACHINE )
121121 msvc = None
122122 for i in [17 , 16 , 15 ]:
123123 try :
124- aKey = winreg .OpenKey (aReg , rf'SOFTWARE\Microsoft\VisualStudio\{ i } .0' )
125- print (f"Found { i } " )
124+ winreg .OpenKey (handle , rf'SOFTWARE\Microsoft\VisualStudio\{ i } .0' )
126125 msvc = i
127126 break
128127 except FileNotFoundError :
129128 pass
130129 return msvc
131130
131+
132132def RemoveDirectory ( directory ):
133133 try_number = 0
134134 max_tries = 10
@@ -424,13 +424,8 @@ def ParseArguments():
424424 help = 'Use system libclang instead of downloading one '
425425 'from llvm.org. NOT RECOMMENDED OR SUPPORTED!' )
426426 if OnWindows ():
427- latest_msvc = FindLatestMSVC ()
428- if latest_msvc is None :
429- # TODO: raise?
430- # raise FileNotFoundError("Could not find a valid MSVC version")
431- latest_msvc = 16
432427 parser .add_argument ( '--msvc' , type = int , choices = [ 15 , 16 , 17 ],
433- default = latest_msvc ,
428+ default = None ,
434429 help = 'Choose the Microsoft Visual Studio version '
435430 '(default: %(default)s).' )
436431 parser .add_argument ( '--ninja' , action = 'store_true' ,
@@ -511,6 +506,11 @@ def ParseArguments():
511506 # We always want a debug build when running with coverage enabled
512507 args .enable_debug = True
513508
509+ if OnWindows () and args .msvc is None :
510+ args .msvc = FindLatestMSVC ()
511+ if args .msvc is None :
512+ raise FileNotFoundError ("Could not find a valid MSVC version" )
513+
514514 if args .core_tests :
515515 os .environ [ 'YCM_TESTRUN' ] = '1'
516516 elif os .environ .get ( 'YCM_TESTRUN' ):
0 commit comments