Skip to content

Commit 09a53d5

Browse files
committed
Modify functionsnapshot_symbol_table by removing the "CrossRef" special case so that testDeprecatedAddFunctionDeprecationIndirectImport passes both with cache and nocache and add some more tests.
1 parent 250e171 commit 09a53d5

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

mypy/server/astdiff.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,7 @@ def snapshot_symbol_table(name_prefix: str, table: SymbolTable) -> dict[str, Sym
217217
)
218218
else:
219219
assert symbol.kind != UNBOUND_IMPORTED
220-
if node and get_prefix(node.fullname) != name_prefix:
221-
# This is a cross-reference to a node defined in another module.
222-
result[name] = ("CrossRef", common)
223-
else:
224-
result[name] = snapshot_definition(node, common)
220+
result[name] = snapshot_definition(node, common)
225221
return result
226222

227223

test-data/unit/fine-grained.test

+36-8
Original file line numberDiff line numberDiff line change
@@ -10546,7 +10546,7 @@ m.py:9: error: Argument 2 to "foo" has incompatible type "str"; expected "int"
1054610546
m.py:10: error: Unexpected keyword argument "a" for "foo"
1054710547
partial.py:4: note: "foo" defined here
1054810548

10549-
[case testAddKeepChangeAndRemoveFunctionDeprecation]
10549+
[case testDeprecatedAddKeepChangeAndRemoveFunctionDeprecation]
1055010550
from a import f
1055110551
f()
1055210552
import a
@@ -10587,7 +10587,7 @@ main:4: note: function a.f is deprecated: use f3 instead
1058710587
==
1058810588

1058910589

10590-
[case testRemoveFunctionDeprecation]
10590+
[case testDeprecatedRemoveFunctionDeprecation]
1059110591
from a import f
1059210592
f()
1059310593
import a
@@ -10607,7 +10607,7 @@ main:1: note: function a.f is deprecated: use f2 instead
1060710607
main:4: note: function a.f is deprecated: use f2 instead
1060810608
==
1060910609

10610-
[case testKeepFunctionDeprecation]
10610+
[case testDeprecatedKeepFunctionDeprecation]
1061110611
from a import f
1061210612
f()
1061310613
import a
@@ -10632,7 +10632,7 @@ main:1: note: function a.f is deprecated: use f2 instead
1063210632
main:4: note: function a.f is deprecated: use f2 instead
1063310633

1063410634

10635-
[case testAddFunctionDeprecationIndirectImport1-only_when_nocache]
10635+
[case testDeprecatedAddFunctionDeprecationIndirectImport]
1063610636
from b import f
1063710637
f()
1063810638
import b
@@ -10649,15 +10649,15 @@ from typing_extensions import deprecated
1064910649
@deprecated("use f2 instead")
1065010650
def f() -> int: ...
1065110651

10652-
1065310652
[builtins fixtures/tuple.pyi]
1065410653
[out]
1065510654
==
10655+
b.py:1: note: function a.f is deprecated: use f2 instead
1065610656
main:1: note: function a.f is deprecated: use f2 instead
1065710657
main:4: note: function a.f is deprecated: use f2 instead
10658-
b.py:1: note: function a.f is deprecated: use f2 instead
1065910658

10660-
[case testAddFunctionDeprecationIndirectImport2-only_when_cache]
10659+
10660+
[case testDeprecatedChangeFunctionDeprecationIndirectImport]
1066110661
from b import f
1066210662
f()
1066310663
import b
@@ -10667,17 +10667,45 @@ b.f()
1066710667
from a import f
1066810668

1066910669
[file a.py]
10670+
from typing_extensions import deprecated
10671+
@deprecated("use f1 instead")
1067010672
def f() -> int: ...
1067110673

1067210674
[file a.py.2]
1067310675
from typing_extensions import deprecated
1067410676
@deprecated("use f2 instead")
1067510677
def f() -> int: ...
1067610678

10677-
1067810679
[builtins fixtures/tuple.pyi]
1067910680
[out]
10681+
b.py:1: note: function a.f is deprecated: use f1 instead
10682+
main:1: note: function a.f is deprecated: use f1 instead
10683+
main:4: note: function a.f is deprecated: use f1 instead
1068010684
==
1068110685
b.py:1: note: function a.f is deprecated: use f2 instead
1068210686
main:1: note: function a.f is deprecated: use f2 instead
1068310687
main:4: note: function a.f is deprecated: use f2 instead
10688+
10689+
[case testDeprecatedRemoveFunctionDeprecationIndirectImport]
10690+
from b import f
10691+
f()
10692+
import b
10693+
b.f()
10694+
10695+
[file b.py]
10696+
from a import f
10697+
10698+
[file a.py]
10699+
from typing_extensions import deprecated
10700+
@deprecated("use f1 instead")
10701+
def f() -> int: ...
10702+
10703+
[file a.py.2]
10704+
def f() -> int: ...
10705+
10706+
[builtins fixtures/tuple.pyi]
10707+
[out]
10708+
b.py:1: note: function a.f is deprecated: use f1 instead
10709+
main:1: note: function a.f is deprecated: use f1 instead
10710+
main:4: note: function a.f is deprecated: use f1 instead
10711+
==

0 commit comments

Comments
 (0)