mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 16:06:39 +03:00
Small cleanup: Renamed diagnostic rule sets for off/basic/strict to match terminology and reordered them so they're in increasing order of strictness.
This commit is contained in:
parent
ed8cab07ee
commit
169fb12ef8
@ -16,7 +16,7 @@ import {
|
||||
} from 'vscode-languageserver';
|
||||
|
||||
import { OperationCanceledException } from '../common/cancellationUtils';
|
||||
import { ConfigOptions, ExecutionEnvironment, getDefaultDiagnosticRuleSet } from '../common/configOptions';
|
||||
import { ConfigOptions, ExecutionEnvironment, getBasicDiagnosticRuleSet } from '../common/configOptions';
|
||||
import { ConsoleInterface, StandardConsole } from '../common/console';
|
||||
import { assert } from '../common/debug';
|
||||
import { convertLevelToCategory, Diagnostic, DiagnosticCategory } from '../common/diagnostic';
|
||||
@ -123,7 +123,7 @@ export class SourceFile {
|
||||
private _checkerDiagnostics: Diagnostic[] = [];
|
||||
|
||||
// Settings that control which diagnostics should be output.
|
||||
private _diagnosticRuleSet = getDefaultDiagnosticRuleSet();
|
||||
private _diagnosticRuleSet = getBasicDiagnosticRuleSet();
|
||||
|
||||
// Circular dependencies that have been reported in this file.
|
||||
private _circularDependencies: CircularDependency[] = [];
|
||||
|
@ -250,58 +250,7 @@ export function getStrictModeNotOverriddenRules() {
|
||||
return [DiagnosticRule.reportMissingModuleSource];
|
||||
}
|
||||
|
||||
export function getStrictDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
const diagSettings: DiagnosticRuleSet = {
|
||||
printUnknownAsAny: false,
|
||||
omitTypeArgsIfAny: false,
|
||||
pep604Printing: true,
|
||||
strictListInference: true,
|
||||
strictDictionaryInference: true,
|
||||
strictParameterNoneValue: true,
|
||||
enableTypeIgnoreComments: true, // Not overridden by strict mode
|
||||
reportGeneralTypeIssues: 'error',
|
||||
reportMissingImports: 'error',
|
||||
reportMissingModuleSource: 'warning',
|
||||
reportMissingTypeStubs: 'error',
|
||||
reportImportCycles: 'error',
|
||||
reportUnusedImport: 'error',
|
||||
reportUnusedClass: 'error',
|
||||
reportUnusedFunction: 'error',
|
||||
reportUnusedVariable: 'error',
|
||||
reportDuplicateImport: 'error',
|
||||
reportOptionalSubscript: 'error',
|
||||
reportOptionalMemberAccess: 'error',
|
||||
reportOptionalCall: 'error',
|
||||
reportOptionalIterable: 'error',
|
||||
reportOptionalContextManager: 'error',
|
||||
reportOptionalOperand: 'error',
|
||||
reportUntypedFunctionDecorator: 'error',
|
||||
reportUntypedClassDecorator: 'error',
|
||||
reportUntypedBaseClass: 'error',
|
||||
reportUntypedNamedTuple: 'error',
|
||||
reportPrivateUsage: 'error',
|
||||
reportConstantRedefinition: 'error',
|
||||
reportIncompatibleMethodOverride: 'error',
|
||||
reportInvalidStringEscapeSequence: 'error',
|
||||
reportUnknownParameterType: 'error',
|
||||
reportUnknownArgumentType: 'error',
|
||||
reportUnknownLambdaType: 'error',
|
||||
reportUnknownVariableType: 'error',
|
||||
reportUnknownMemberType: 'error',
|
||||
reportCallInDefaultInitializer: 'none',
|
||||
reportUnnecessaryIsInstance: 'error',
|
||||
reportUnnecessaryCast: 'error',
|
||||
reportAssertAlwaysTrue: 'error',
|
||||
reportSelfClsParameterName: 'error',
|
||||
reportImplicitStringConcatenation: 'none',
|
||||
reportUnboundVariable: 'error',
|
||||
reportUndefinedVariable: 'error',
|
||||
};
|
||||
|
||||
return diagSettings;
|
||||
}
|
||||
|
||||
export function getNoTypeCheckingDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
export function getOffDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
const diagSettings: DiagnosticRuleSet = {
|
||||
printUnknownAsAny: true,
|
||||
omitTypeArgsIfAny: true,
|
||||
@ -352,7 +301,7 @@ export function getNoTypeCheckingDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
return diagSettings;
|
||||
}
|
||||
|
||||
export function getDefaultDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
export function getBasicDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
const diagSettings: DiagnosticRuleSet = {
|
||||
printUnknownAsAny: false,
|
||||
omitTypeArgsIfAny: false,
|
||||
@ -403,6 +352,57 @@ export function getDefaultDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
return diagSettings;
|
||||
}
|
||||
|
||||
export function getStrictDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
const diagSettings: DiagnosticRuleSet = {
|
||||
printUnknownAsAny: false,
|
||||
omitTypeArgsIfAny: false,
|
||||
pep604Printing: true,
|
||||
strictListInference: true,
|
||||
strictDictionaryInference: true,
|
||||
strictParameterNoneValue: true,
|
||||
enableTypeIgnoreComments: true, // Not overridden by strict mode
|
||||
reportGeneralTypeIssues: 'error',
|
||||
reportMissingImports: 'error',
|
||||
reportMissingModuleSource: 'warning',
|
||||
reportMissingTypeStubs: 'error',
|
||||
reportImportCycles: 'error',
|
||||
reportUnusedImport: 'error',
|
||||
reportUnusedClass: 'error',
|
||||
reportUnusedFunction: 'error',
|
||||
reportUnusedVariable: 'error',
|
||||
reportDuplicateImport: 'error',
|
||||
reportOptionalSubscript: 'error',
|
||||
reportOptionalMemberAccess: 'error',
|
||||
reportOptionalCall: 'error',
|
||||
reportOptionalIterable: 'error',
|
||||
reportOptionalContextManager: 'error',
|
||||
reportOptionalOperand: 'error',
|
||||
reportUntypedFunctionDecorator: 'error',
|
||||
reportUntypedClassDecorator: 'error',
|
||||
reportUntypedBaseClass: 'error',
|
||||
reportUntypedNamedTuple: 'error',
|
||||
reportPrivateUsage: 'error',
|
||||
reportConstantRedefinition: 'error',
|
||||
reportIncompatibleMethodOverride: 'error',
|
||||
reportInvalidStringEscapeSequence: 'error',
|
||||
reportUnknownParameterType: 'error',
|
||||
reportUnknownArgumentType: 'error',
|
||||
reportUnknownLambdaType: 'error',
|
||||
reportUnknownVariableType: 'error',
|
||||
reportUnknownMemberType: 'error',
|
||||
reportCallInDefaultInitializer: 'none',
|
||||
reportUnnecessaryIsInstance: 'error',
|
||||
reportUnnecessaryCast: 'error',
|
||||
reportAssertAlwaysTrue: 'error',
|
||||
reportSelfClsParameterName: 'error',
|
||||
reportImplicitStringConcatenation: 'none',
|
||||
reportUnboundVariable: 'error',
|
||||
reportUndefinedVariable: 'error',
|
||||
};
|
||||
|
||||
return diagSettings;
|
||||
}
|
||||
|
||||
// Internal configuration options. These are derived from a combination
|
||||
// of the command line and from a JSON-based config file.
|
||||
export class ConfigOptions {
|
||||
@ -498,10 +498,10 @@ export class ConfigOptions {
|
||||
}
|
||||
|
||||
if (typeCheckingMode === 'off') {
|
||||
return getNoTypeCheckingDiagnosticRuleSet();
|
||||
return getOffDiagnosticRuleSet();
|
||||
}
|
||||
|
||||
return getDefaultDiagnosticRuleSet();
|
||||
return getBasicDiagnosticRuleSet();
|
||||
}
|
||||
|
||||
// Finds the best execution environment for a given file path. The
|
||||
|
Loading…
Reference in New Issue
Block a user