mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-16 19:30:26 +03:00
Added new diagnostic rule reportPossiblyUnboundVariable
, which is split off from reportUnboundVariable
. This addresses #6896. (#7071)
This commit is contained in:
parent
aa64fc5dec
commit
91960fba49
@ -132,6 +132,8 @@ The following settings control pyright’s diagnostic output (warnings or errors
|
||||
|
||||
<a name="reportOverlappingOverload"></a> **reportOverlappingOverload** [boolean or string, optional]: Generate or suppress diagnostics for function overloads that overlap in signature and obscure each other or have incompatible return types. The default value for this setting is `"error"`.
|
||||
|
||||
<a name="reportPossiblyUnboundVariable"></a> **reportPossiblyUnboundVariable** [boolean or string, optional]: Generate or suppress diagnostics for variables that are possibly unbound on some code paths. The default value for this setting is `"error"`. The default value for this setting is `"error"`.
|
||||
|
||||
<a name="reportMissingSuperCall"></a> **reportMissingSuperCall** [boolean or string, optional]: Generate or suppress diagnostics for `__init__`, `__init_subclass__`, `__enter__` and `__exit__` methods in a subclass that fail to call through to the same-named method on a base class. The default value for this setting is `"none"`.
|
||||
|
||||
<a name="reportUninitializedInstanceVariable"></a> **reportUninitializedInstanceVariable** [boolean or string, optional]: Generate or suppress diagnostics for instance variables within a class that are not initialized or declared within the class body or the `__init__` method. The default value for this setting is `"none"`.
|
||||
@ -172,7 +174,7 @@ The following settings control pyright’s diagnostic output (warnings or errors
|
||||
|
||||
<a name="reportUndefinedVariable"></a> **reportUndefinedVariable** [boolean or string, optional]: Generate or suppress diagnostics for undefined variables. The default value for this setting is `"error"`.
|
||||
|
||||
<a name="reportUnboundVariable"></a> **reportUnboundVariable** [boolean or string, optional]: Generate or suppress diagnostics for unbound and possibly unbound variables. The default value for this setting is `"error"`.
|
||||
<a name="reportUnboundVariable"></a> **reportUnboundVariable** [boolean or string, optional]: Generate or suppress diagnostics for unbound variables. The default value for this setting is `"error"`.
|
||||
|
||||
<a name="reportInvalidStubStatement"></a> **reportInvalidStubStatement** [boolean or string, optional]: Generate or suppress diagnostics for statements that are syntactically correct but have no purpose within a type stub file. The default value for this setting is `"none"`.
|
||||
|
||||
@ -344,6 +346,7 @@ The following table lists the default severity levels for each diagnostic rule w
|
||||
| reportIncompatibleMethodOverride | "none" | "none" | "error" | "error" |
|
||||
| reportIncompatibleVariableOverride | "none" | "none" | "error" | "error" |
|
||||
| reportOverlappingOverload | "none" | "none" | "error" | "error" |
|
||||
| reportPossiblyUnboundVariable | "none" | "none" | "error" | "error" |
|
||||
| reportConstantRedefinition | "none" | "none" | "none" | "error" |
|
||||
| reportDeprecated | "none" | "none" | "none" | "error" |
|
||||
| reportDuplicateImport | "none" | "none" | "none" | "error" |
|
||||
|
@ -4266,7 +4266,7 @@ export class Checker extends ParseTreeWalker {
|
||||
);
|
||||
} else if (isPossiblyUnbound(type)) {
|
||||
this._evaluator.addDiagnostic(
|
||||
DiagnosticRule.reportUnboundVariable,
|
||||
DiagnosticRule.reportPossiblyUnboundVariable,
|
||||
LocMessage.symbolIsPossiblyUnbound().format({ name: node.value }),
|
||||
node
|
||||
);
|
||||
|
@ -227,6 +227,9 @@ export interface DiagnosticRuleSet {
|
||||
// incompatible return types.
|
||||
reportOverlappingOverload: DiagnosticLevel;
|
||||
|
||||
// Report usage of possibly unbound variables.
|
||||
reportPossiblyUnboundVariable: DiagnosticLevel;
|
||||
|
||||
// Report failure to call super().__init__() in __init__ method.
|
||||
reportMissingSuperCall: DiagnosticLevel;
|
||||
|
||||
@ -291,7 +294,7 @@ export interface DiagnosticRuleSet {
|
||||
// Report usage of undefined variables.
|
||||
reportUndefinedVariable: DiagnosticLevel;
|
||||
|
||||
// Report usage of unbound or possibly unbound variables.
|
||||
// Report usage of unbound variables.
|
||||
reportUnboundVariable: DiagnosticLevel;
|
||||
|
||||
// Report statements that are syntactically correct but
|
||||
@ -402,6 +405,7 @@ export function getDiagLevelDiagnosticRules() {
|
||||
DiagnosticRule.reportIncompatibleVariableOverride,
|
||||
DiagnosticRule.reportInconsistentConstructor,
|
||||
DiagnosticRule.reportOverlappingOverload,
|
||||
DiagnosticRule.reportPossiblyUnboundVariable,
|
||||
DiagnosticRule.reportMissingSuperCall,
|
||||
DiagnosticRule.reportUninitializedInstanceVariable,
|
||||
DiagnosticRule.reportInvalidStringEscapeSequence,
|
||||
@ -494,6 +498,7 @@ export function getOffDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
reportIncompatibleVariableOverride: 'none',
|
||||
reportInconsistentConstructor: 'none',
|
||||
reportOverlappingOverload: 'none',
|
||||
reportPossiblyUnboundVariable: 'none',
|
||||
reportMissingSuperCall: 'none',
|
||||
reportUninitializedInstanceVariable: 'none',
|
||||
reportInvalidStringEscapeSequence: 'none',
|
||||
@ -582,6 +587,7 @@ export function getBasicDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
reportIncompatibleVariableOverride: 'none',
|
||||
reportInconsistentConstructor: 'none',
|
||||
reportOverlappingOverload: 'none',
|
||||
reportPossiblyUnboundVariable: 'none',
|
||||
reportMissingSuperCall: 'none',
|
||||
reportUninitializedInstanceVariable: 'none',
|
||||
reportInvalidStringEscapeSequence: 'warning',
|
||||
@ -670,6 +676,7 @@ export function getStandardDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
reportIncompatibleVariableOverride: 'error',
|
||||
reportInconsistentConstructor: 'none',
|
||||
reportOverlappingOverload: 'error',
|
||||
reportPossiblyUnboundVariable: 'error',
|
||||
reportMissingSuperCall: 'none',
|
||||
reportUninitializedInstanceVariable: 'none',
|
||||
reportInvalidStringEscapeSequence: 'warning',
|
||||
@ -758,6 +765,7 @@ export function getStrictDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
reportIncompatibleVariableOverride: 'error',
|
||||
reportInconsistentConstructor: 'error',
|
||||
reportOverlappingOverload: 'error',
|
||||
reportPossiblyUnboundVariable: 'error',
|
||||
reportMissingSuperCall: 'none',
|
||||
reportUninitializedInstanceVariable: 'none',
|
||||
reportInvalidStringEscapeSequence: 'error',
|
||||
|
@ -56,6 +56,7 @@ export enum DiagnosticRule {
|
||||
reportIncompatibleVariableOverride = 'reportIncompatibleVariableOverride',
|
||||
reportInconsistentConstructor = 'reportInconsistentConstructor',
|
||||
reportOverlappingOverload = 'reportOverlappingOverload',
|
||||
reportPossiblyUnboundVariable = 'reportPossiblyUnboundVariable',
|
||||
reportMissingSuperCall = 'reportMissingSuperCall',
|
||||
reportUninitializedInstanceVariable = 'reportUninitializedInstanceVariable',
|
||||
reportInvalidStringEscapeSequence = 'reportInvalidStringEscapeSequence',
|
||||
|
@ -751,6 +751,22 @@
|
||||
false
|
||||
]
|
||||
},
|
||||
"reportPossiblyUnboundVariable": {
|
||||
"type": [
|
||||
"string",
|
||||
"boolean"
|
||||
],
|
||||
"description": "Diagnostics for the use of variables that may be unbound on some code paths.",
|
||||
"default": "error",
|
||||
"enum": [
|
||||
"none",
|
||||
"information",
|
||||
"warning",
|
||||
"error",
|
||||
true,
|
||||
false
|
||||
]
|
||||
},
|
||||
"reportMissingSuperCall": {
|
||||
"type": [
|
||||
"string",
|
||||
@ -1108,7 +1124,7 @@
|
||||
"string",
|
||||
"boolean"
|
||||
],
|
||||
"description": "Diagnostics for unbound and possibly unbound variables.",
|
||||
"description": "Diagnostics for the use of unbound variables.",
|
||||
"default": "error",
|
||||
"enum": [
|
||||
"none",
|
||||
|
@ -377,6 +377,12 @@
|
||||
"title": "Controls reporting of function overloads that overlap in signature and obscure each other or do not agree on return type",
|
||||
"default": "error"
|
||||
},
|
||||
"reportPossiblyUnboundVariable": {
|
||||
"$id": "#/properties/reportPossiblyUnboundVariable",
|
||||
"$ref": "#/definitions/diagnostic",
|
||||
"title": "Controls reporting of attempts to use variable that is possibly unbound on some code paths",
|
||||
"default": "error"
|
||||
},
|
||||
"reportMissingSuperCall": {
|
||||
"$id": "#/properties/reportMissingSuperCall",
|
||||
"$ref": "#/definitions/diagnostic",
|
||||
@ -494,7 +500,7 @@
|
||||
"reportUnboundVariable": {
|
||||
"$id": "#/properties/reportUnboundVariable",
|
||||
"$ref": "#/definitions/diagnostic",
|
||||
"title": "Controls reporting of attempts to use an unbound or possibly unbound variable",
|
||||
"title": "Controls reporting of attempts to use an unbound variable",
|
||||
"default": "error"
|
||||
},
|
||||
"reportUndefinedVariable": {
|
||||
|
Loading…
Reference in New Issue
Block a user