@@ -43,34 +43,6 @@ function resolveVariables(value: string[], workspace?: WorkspaceFolder): string[
4343 } ) ;
4444}
4545
46- function getArgs ( namespace : string , workspace : WorkspaceFolder ) : string [ ] {
47- const config = getConfiguration ( namespace , workspace . uri ) ;
48- const args = config . get < string [ ] > ( 'args' , [ ] ) ;
49-
50- if ( args . length > 0 ) {
51- return args ;
52- }
53-
54- const legacyConfig = getConfiguration ( 'python' , workspace . uri ) ;
55- return legacyConfig . get < string [ ] > ( 'formatting.blackArgs' , [ ] ) ;
56- }
57-
58- function getPath ( namespace : string , workspace : WorkspaceFolder ) : string [ ] {
59- const config = getConfiguration ( namespace , workspace . uri ) ;
60- const path = config . get < string [ ] > ( 'path' , [ ] ) ;
61-
62- if ( path . length > 0 ) {
63- return path ;
64- }
65-
66- const legacyConfig = getConfiguration ( 'python' , workspace . uri ) ;
67- const legacyPath = legacyConfig . get < string > ( 'formatting.blackPath' , '' ) ;
68- if ( legacyPath . length > 0 && legacyPath !== 'black' ) {
69- return [ legacyPath ] ;
70- }
71- return [ ] ;
72- }
73-
7446export function getInterpreterFromSetting ( namespace : string , scope ?: ConfigurationScope ) {
7547 const config = getConfiguration ( namespace , scope ) ;
7648 return config . get < string [ ] > ( 'interpreter' ) ;
@@ -105,13 +77,11 @@ export async function getWorkspaceSettings(
10577 }
10678 }
10779
108- const args = getArgs ( namespace , workspace ) ;
109- const path = getPath ( namespace , workspace ) ;
11080 const workspaceSetting = {
11181 cwd : workspace . uri . fsPath ,
11282 workspace : workspace . uri . toString ( ) ,
113- args : resolveVariables ( args , workspace ) ,
114- path : resolveVariables ( path , workspace ) ,
83+ args : resolveVariables ( config . get < string [ ] > ( ' args' , [ ] ) , workspace ) ,
84+ path : resolveVariables ( config . get < string [ ] > ( ' path' , [ ] ) , workspace ) ,
11585 interpreter : resolveVariables ( interpreter , workspace ) ,
11686 importStrategy : config . get < string > ( 'importStrategy' , 'fromEnvironment' ) ,
11787 showNotifications : config . get < string > ( 'showNotifications' , 'off' ) ,
@@ -177,3 +147,26 @@ export function logDefaultFormatter(): void {
177147 }
178148 } ) ;
179149}
150+
151+ export function logLegacySettings ( ) : void {
152+ getWorkspaceFolders ( ) . forEach ( ( workspace ) => {
153+ try {
154+ const legacyConfig = getConfiguration ( 'python' , workspace . uri ) ;
155+ const legacyArgs = legacyConfig . get < string [ ] > ( 'formatting.blackArgs' , [ ] ) ;
156+ const legacyPath = legacyConfig . get < string > ( 'formatting.blackPath' , '' ) ;
157+ if ( legacyArgs . length > 0 ) {
158+ traceWarn ( `"python.formatting.blackArgs" is deprecated. Use "black-formatter.args" instead.` ) ;
159+ traceWarn ( `"python.formatting.blackArgs" for workspace ${ workspace . uri . fsPath } :` ) ;
160+ traceWarn ( `\n${ JSON . stringify ( legacyArgs , null , 4 ) } ` ) ;
161+ }
162+
163+ if ( legacyPath . length > 0 && legacyPath !== 'black' ) {
164+ traceWarn ( `"python.formatting.blackPath" is deprecated. Use "black-formatter.path" instead.` ) ;
165+ traceWarn ( `"python.formatting.blackPath" for workspace ${ workspace . uri . fsPath } :` ) ;
166+ traceWarn ( `\n${ JSON . stringify ( legacyPath , null , 4 ) } ` ) ;
167+ }
168+ } catch ( err ) {
169+ traceWarn ( `Error while logging legacy settings: ${ err } ` ) ;
170+ }
171+ } ) ;
172+ }
0 commit comments