@@ -115,57 +115,57 @@ def Exit( self ):
115
115
'See the YCM docs for details on how to use a custom Clangd.' )
116
116
117
117
118
- def FindLatestMSVC (quiet ):
119
- ACCEPTABLE_VERSIONS = [17 , 16 , 15 ]
118
+ def FindLatestMSVC ( quiet ):
119
+ ACCEPTABLE_VERSIONS = [ 17 , 16 , 15 ]
120
120
121
- VSWHERE_EXE = os .path .join (os .environ ['ProgramFiles(x86)' ],
121
+ VSWHERE_EXE = os .path .join ( os .environ [ 'ProgramFiles(x86)' ],
122
122
'Microsoft Visual Studio' ,
123
- 'Installer' , 'vswhere.exe' )
123
+ 'Installer' , 'vswhere.exe' )
124
124
125
- if os .path .exists (VSWHERE_EXE ):
125
+ if os .path .exists ( VSWHERE_EXE ):
126
126
if not quiet :
127
- print ("Calling vswhere -latest -installationVersion" )
127
+ print ( "Calling vswhere -latest -installationVersion" )
128
128
latest_full_v = subprocess .check_output (
129
- [VSWHERE_EXE , '-latest' , '-property' , 'installationVersion' ]
129
+ [ VSWHERE_EXE , '-latest' , '-property' , 'installationVersion' ]
130
130
).strip ().decode ()
131
131
if '.' in latest_full_v :
132
132
try :
133
- latest_v = int (latest_full_v .split ('.' )[ 0 ] )
133
+ latest_v = int ( latest_full_v .split ( '.' )[ 0 ] )
134
134
except ValueError :
135
- raise ValueError ("{latest_full_v=} is not a version number." )
135
+ raise ValueError ( "{latest_full_v=} is not a version number." )
136
136
137
137
if not quiet :
138
- print (f'vswhere -latest returned version { latest_full_v = } ' )
138
+ print ( f'vswhere -latest returned version { latest_full_v = } ' )
139
139
140
140
if latest_v not in ACCEPTABLE_VERSIONS :
141
141
if latest_v > 17 :
142
142
if not quiet :
143
- print (f'MSVC Version { latest_full_v = } is newer than expected.' )
143
+ print ( f'MSVC Version { latest_full_v = } is newer than expected.' )
144
144
else :
145
145
raise ValueError (
146
146
f'vswhere returned { latest_full_v = } which is unexpected.'
147
- 'Pass --msvc <version> argument.' )
147
+ 'Pass --msvc <version> argument.' )
148
148
return latest_v
149
149
else :
150
150
if not quiet :
151
- print (f'vswhere returned nothing usable, { latest_full_v = } ' )
151
+ print ( f'vswhere returned nothing usable, { latest_full_v = } ' )
152
152
153
153
# Fall back to registry parsing, which works at least until MSVC 2019 (16)
154
154
# but is likely failing on MSVC 2022 (17)
155
155
if not quiet :
156
- print ("vswhere method failed, falling back to searching the registry" )
156
+ print ( "vswhere method failed, falling back to searching the registry" )
157
157
158
158
import winreg
159
- handle = winreg .ConnectRegistry (None , winreg .HKEY_LOCAL_MACHINE )
159
+ handle = winreg .ConnectRegistry ( None , winreg .HKEY_LOCAL_MACHINE )
160
160
msvc = None
161
161
for i in ACCEPTABLE_VERSIONS :
162
162
if not quiet :
163
- print ('Trying to find '
164
- rf'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\{ i } .0' )
163
+ print ( 'Trying to find '
164
+ rf'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\{ i } .0' )
165
165
try :
166
- winreg .OpenKey (handle , rf'SOFTWARE\Microsoft\VisualStudio\{ i } .0' )
166
+ winreg .OpenKey ( handle , rf'SOFTWARE\Microsoft\VisualStudio\{ i } .0' )
167
167
if not quiet :
168
- print (f"Found MSVC version { i } " )
168
+ print ( f"Found MSVC version { i } " )
169
169
msvc = i
170
170
break
171
171
except FileNotFoundError :
@@ -468,7 +468,7 @@ def ParseArguments():
468
468
help = 'Use system libclang instead of downloading one '
469
469
'from llvm.org. NOT RECOMMENDED OR SUPPORTED!' )
470
470
if OnWindows ():
471
- parser .add_argument ( '--msvc' , type = int , choices = [ 15 , 16 , 17 ],
471
+ parser .add_argument ( '--msvc' , type = int , choices = [ 15 , 16 , 17 ],
472
472
default = None ,
473
473
help = 'Choose the Microsoft Visual Studio version '
474
474
'(default: %(default)s).' )
@@ -551,9 +551,9 @@ def ParseArguments():
551
551
args .enable_debug = True
552
552
553
553
if OnWindows () and args .msvc is None :
554
- args .msvc = FindLatestMSVC (args .quiet )
554
+ args .msvc = FindLatestMSVC ( args .quiet )
555
555
if args .msvc is None :
556
- raise FileNotFoundError ("Could not find a valid MSVC version." )
556
+ raise FileNotFoundError ( "Could not find a valid MSVC version." )
557
557
558
558
if args .core_tests :
559
559
os .environ [ 'YCM_TESTRUN' ] = '1'
0 commit comments