mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-17 03:40:44 +03:00
Changed the reportUnboundVariable
default severity from "warning" to "none" when typeCheckingMode is "off". There were too many complaints of false positives from users who have no interest in type checking.
This commit is contained in:
parent
df5bf6551b
commit
36c168c1ae
@ -271,7 +271,7 @@ The following table lists the default severity levels for each diagnostic rule w
|
||||
| reportSelfClsParameterName | "none" | "warning" | "error" |
|
||||
| reportImplicitStringConcatenation | "none" | "none" | "none" |
|
||||
| reportUndefinedVariable | "warning" | "error" | "error" |
|
||||
| reportUnboundVariable | "warning" | "error" | "error" |
|
||||
| reportUnboundVariable | "none" | "error" | "error" |
|
||||
| reportInvalidStubStatement | "none" | "none" | "error" |
|
||||
| reportUnsupportedDunderAll | "none" | "warning" | "error" |
|
||||
| reportUnusedCallResult | "none" | "none" | "none" |
|
||||
|
@ -369,7 +369,7 @@ export function getOffDiagnosticRuleSet(): DiagnosticRuleSet {
|
||||
reportAssertAlwaysTrue: 'none',
|
||||
reportSelfClsParameterName: 'none',
|
||||
reportImplicitStringConcatenation: 'none',
|
||||
reportUnboundVariable: 'warning',
|
||||
reportUnboundVariable: 'none',
|
||||
reportUndefinedVariable: 'warning',
|
||||
reportInvalidStubStatement: 'none',
|
||||
reportUnsupportedDunderAll: 'none',
|
||||
|
48
packages/pyright-internal/src/tests/samples/forLoop2.py
Normal file
48
packages/pyright-internal/src/tests/samples/forLoop2.py
Normal file
@ -0,0 +1,48 @@
|
||||
# This sample tests for/else loops for cases where variables
|
||||
# are potentially unbound.
|
||||
|
||||
|
||||
# For with no break and no else.
|
||||
def func1():
|
||||
for x in []:
|
||||
a = 0
|
||||
|
||||
# This should generate a "potentially unbound" error.
|
||||
print(a)
|
||||
|
||||
# This should generate a "potentially unbound" error.
|
||||
print(x)
|
||||
|
||||
|
||||
# For with no break and else.
|
||||
def func2():
|
||||
for x in []:
|
||||
a = 0
|
||||
else:
|
||||
b = 0
|
||||
|
||||
# This should generate a "potentially unbound" error.
|
||||
print(a)
|
||||
|
||||
print(b)
|
||||
|
||||
# This should generate a "potentially unbound" error.
|
||||
print(x)
|
||||
|
||||
|
||||
# For with break and else.
|
||||
def func3():
|
||||
for x in []:
|
||||
a = 0
|
||||
break
|
||||
else:
|
||||
b = 0
|
||||
|
||||
# This should generate a "potentially unbound" error.
|
||||
print(a)
|
||||
|
||||
# This should generate a "potentially unbound" error.
|
||||
print(b)
|
||||
|
||||
# This should generate a "potentially unbound" error.
|
||||
print(x)
|
@ -966,12 +966,18 @@ test('Loops6', () => {
|
||||
TestUtils.validateResults(analysisResults, 0);
|
||||
});
|
||||
|
||||
test('ForLoops1', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['forLoops1.py']);
|
||||
test('ForLoop1', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['forLoop1.py']);
|
||||
|
||||
TestUtils.validateResults(analysisResults, 2);
|
||||
});
|
||||
|
||||
test('ForLoop2', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['forLoop2.py']);
|
||||
|
||||
TestUtils.validateResults(analysisResults, 7);
|
||||
});
|
||||
|
||||
test('ListComprehension1', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['listComprehension1.py']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user