Skip to content

Commit

Permalink
refactor: configuration update for 2023.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yaegassy committed Oct 11, 2023
1 parent 4515d60 commit 59672b7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,26 @@
},
"type": "array"
},
"mypy-type-checker.preferDaemon": {
"default": true,
"markdownDescription": "When set to true, `dmypy` is preferred over `mypy`; otherwise, `mypy` is preferred. This setting will be overridden if `mypy-type-checker.path` is set. NOTE: Setting this option to false may slowdown linting.",
"scope": "resource",
"type": "boolean"
},
"mypy-type-checker.reportingScope": {
"default": "file",
"markdownDescription": "Defines the scope of the problems reported by the extension.",
"enum": [
"file",
"workspace"
],
"markdownEnumDescriptions": [
"Problems are reported for the files open in the editor only.",
"Problems are reported for files in the workspace."
],
"scope": "resource",
"type": "string"
},
"mypy-type-checker.severity": {
"default": {
"error": "Error",
Expand Down
26 changes: 17 additions & 9 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,24 @@ export async function createLanguageClient(context: ExtensionContext) {
return client;
}

type ImportStrategy = 'fromEnvironment' | 'useBundled';
type Severity = 'Error' | 'Hint' | 'Information' | 'Warning';
type ShowNotifications = 'off' | 'onError' | 'onWarning' | 'always';
const DEFAULT_SEVERITY: Record<string, string> = {
error: 'Error',
note: 'Information',
};

type ExtensionInitializationOptions = {
globalSettings: {
cwd: string;
workspace: string;
args: string[];
severity: Record<string, string>;
path: string[];
importStrategy: ImportStrategy;
interpreter: string[];
severity: Severity;
showNotifications: ShowNotifications;
importStrategy: string;
showNotifications: string;
extraPaths: string[];
reportingScope: string;
preferDaemon: boolean;
};
};

Expand All @@ -67,11 +71,15 @@ function convertFromWorkspaceConfigToInitializationOptions() {
cwd: workspace.root,
workspace: Uri.parse(workspace.root).toString(),
args: settings.get('args'),
severity: settings.get<Record<string, string>>('severity', DEFAULT_SEVERITY),
path: settings.get('path'),
importStrategy: settings.get<ImportStrategy>(`importStrategy`) ?? 'fromEnvironment',
interpreter: settings.get('interpreter'),
severity: settings.get<Severity>('severity'),
showNotifications: settings.get<ShowNotifications>('showNotifications'),
//importStrategy: settings.get<ImportStrategy>(`importStrategy`) ?? 'fromEnvironment',
importStrategy: settings.get<string>('importStrategy', 'useBundled'),
showNotifications: settings.get<string>('showNotifications', 'off'),
extraPaths: [],
reportingScope: settings.get<string>('reportingScope', 'file'),
preferDaemon: settings.get<boolean>('preferDaemon', true),
},
settings: {},
};
Expand Down

0 comments on commit 59672b7

Please sign in to comment.