Skip to content

Commit 8267da1

Browse files
committed
Fix test failures
1 parent ec6b98d commit 8267da1

4 files changed

Lines changed: 15 additions & 12 deletions

File tree

mypy/semanal.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7567,7 +7567,7 @@ def fail(
75677567
if self.errors._filter_error(self.errors.file, err_info):
75687568
return
75697569

7570-
if self.associated_node is None or self.options.semantic_analysis_only:
7570+
if blocker or self.associated_node is None or self.options.semantic_analysis_only:
75717571
self.errors.add_error_info(err_info)
75727572
else:
75737573
node = self.associated_node
@@ -8155,6 +8155,8 @@ def isolated_error_analysis(self) -> Iterator[None]:
81558155
original_deferral_debug_context_len = len(self.deferral_debug_context)
81568156

81578157
self.errors = Errors(Options())
8158+
previous_association = self.associated_node
8159+
self.associated_node = None
81588160
try:
81598161
yield
81608162
finally:
@@ -8163,6 +8165,7 @@ def isolated_error_analysis(self) -> Iterator[None]:
81638165
self.num_incomplete_refs = original_num_incomplete_refs
81648166
self.progress = original_progress
81658167
self.deferred = original_deferred
8168+
self.associated_node = previous_association
81668169
del self.deferral_debug_context[original_deferral_debug_context_len:]
81678170

81688171

test-data/unit/check-incomplete-fixture.test

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,48 @@ m.x # E: "object" has no attribute "x"
1616
from typing import Set
1717
def f(x: Set[int]) -> None: pass
1818
[out]
19-
main:1: error: Module "typing" has no attribute "Set"
2019
main:1: note: Maybe your test fixture does not define "builtins.set"?
2120
main:1: note: Consider adding [builtins fixtures/set.pyi] to your test description
21+
main:1: error: Module "typing" has no attribute "Set"
2222

2323
[case testBaseExceptionMissingFromStubs]
2424
e: BaseException
2525
[out]
26-
main:1: error: Name "BaseException" is not defined
2726
main:1: note: Maybe your test fixture does not define "builtins.BaseException"?
2827
main:1: note: Consider adding [builtins fixtures/exception.pyi] to your test description
28+
main:1: error: Name "BaseException" is not defined
2929

3030
[case testExceptionMissingFromStubs]
3131
e: Exception
3232
[out]
33-
main:1: error: Name "Exception" is not defined
3433
main:1: note: Maybe your test fixture does not define "builtins.Exception"?
3534
main:1: note: Consider adding [builtins fixtures/exception.pyi] to your test description
35+
main:1: error: Name "Exception" is not defined
3636

3737
[case testIsinstanceMissingFromStubs]
3838
if isinstance(1, int):
3939
pass
4040
[out]
41-
main:1: error: Name "isinstance" is not defined
4241
main:1: note: Maybe your test fixture does not define "builtins.isinstance"?
4342
main:1: note: Consider adding [builtins fixtures/isinstancelist.pyi] to your test description
43+
main:1: error: Name "isinstance" is not defined
4444

4545
[case testTupleMissingFromStubs1]
4646
tuple()
4747
[out]
48-
main:1: error: Name "tuple" is not defined
4948
main:1: note: Maybe your test fixture does not define "builtins.tuple"?
5049
main:1: note: Consider adding [builtins fixtures/tuple.pyi] to your test description
50+
main:1: error: Name "tuple" is not defined
5151
main:1: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
5252

5353
[case testTupleMissingFromStubs2]
5454
tuple()
5555
from typing import Tuple
5656
x: Tuple[int, str]
5757
[out]
58-
main:1: error: Name "tuple" is not defined
5958
main:1: note: Maybe your test fixture does not define "builtins.tuple"?
6059
main:1: note: Consider adding [builtins fixtures/tuple.pyi] to your test description
60+
main:1: error: Name "tuple" is not defined
6161
main:1: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
6262
main:3: error: Name "tuple" is not defined
6363

@@ -66,15 +66,15 @@ class A:
6666
@classmethod
6767
def f(cls): pass
6868
[out]
69-
main:2: error: Name "classmethod" is not defined
7069
main:2: note: Maybe your test fixture does not define "builtins.classmethod"?
7170
main:2: note: Consider adding [builtins fixtures/classmethod.pyi] to your test description
71+
main:2: error: Name "classmethod" is not defined
7272

7373
[case testPropertyMissingFromStubs]
7474
class A:
7575
@property
7676
def f(self): pass
7777
[out]
78-
main:2: error: Name "property" is not defined
7978
main:2: note: Maybe your test fixture does not define "builtins.property"?
8079
main:2: note: Consider adding [builtins fixtures/property.pyi] to your test description
80+
main:2: error: Name "property" is not defined

test-data/unit/check-statements.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,9 +2359,9 @@ from typing import _FutureFeatureFixture
23592359
# that day comes this suggestion will also be less helpful than it is today.
23602360
import typing_extensions
23612361
[out]
2362-
main:1: error: Module "typing" has no attribute "_FutureFeatureFixture"
23632362
main:1: note: Use `from typing_extensions import _FutureFeatureFixture` instead
23642363
main:1: note: See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module
2364+
main:1: error: Module "typing" has no attribute "_FutureFeatureFixture"
23652365
[builtins fixtures/tuple.pyi]
23662366

23672367
[case testNoCrashOnBreakOutsideLoopFunction]

test-data/unit/check-typevar-defaults.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,8 @@ reveal_type(C) # N: Revealed type is "def [T2 = Any] () -> __main__.C[T2`1 = An
930930
c: C
931931
reveal_type(c) # N: Revealed type is "__main__.C[Any]"
932932

933-
class D(Generic[T2, T1]): ... # E: Type variable T1 referenced in the default of T2 is unbound \
934-
# E: "T1" cannot appear after "T2" in type parameter list because it has no default type
933+
class D(Generic[T2, T1]): ... # E: "T1" cannot appear after "T2" in type parameter list because it has no default type \
934+
# E: Type variable T1 referenced in the default of T2 is unbound
935935
reveal_type(D) # N: Revealed type is "def [T2 = Any, T1 = Any] () -> __main__.D[T2`1 = Any, T1`2 = Any]"
936936
d: D
937937
reveal_type(d) # N: Revealed type is "__main__.D[Any, Any]"

0 commit comments

Comments
 (0)