Skip to content

Commit

Permalink
Modify functionsnapshot_symbol_table by removing the "CrossRef" spe…
Browse files Browse the repository at this point in the history
…cial case so that `testDeprecatedAddFunctionDeprecationIndirectImport` passes both with `cache` and `nocache` and add some more tests.
  • Loading branch information
tyralla committed Sep 29, 2024
1 parent 250e171 commit 09a53d5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
6 changes: 1 addition & 5 deletions mypy/server/astdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,7 @@ def snapshot_symbol_table(name_prefix: str, table: SymbolTable) -> dict[str, Sym
)
else:
assert symbol.kind != UNBOUND_IMPORTED
if node and get_prefix(node.fullname) != name_prefix:
# This is a cross-reference to a node defined in another module.
result[name] = ("CrossRef", common)
else:
result[name] = snapshot_definition(node, common)
result[name] = snapshot_definition(node, common)
return result


Expand Down
44 changes: 36 additions & 8 deletions test-data/unit/fine-grained.test
Original file line number Diff line number Diff line change
Expand Up @@ -10546,7 +10546,7 @@ m.py:9: error: Argument 2 to "foo" has incompatible type "str"; expected "int"
m.py:10: error: Unexpected keyword argument "a" for "foo"
partial.py:4: note: "foo" defined here

[case testAddKeepChangeAndRemoveFunctionDeprecation]
[case testDeprecatedAddKeepChangeAndRemoveFunctionDeprecation]
from a import f
f()
import a
Expand Down Expand Up @@ -10587,7 +10587,7 @@ main:4: note: function a.f is deprecated: use f3 instead
==


[case testRemoveFunctionDeprecation]
[case testDeprecatedRemoveFunctionDeprecation]
from a import f
f()
import a
Expand All @@ -10607,7 +10607,7 @@ main:1: note: function a.f is deprecated: use f2 instead
main:4: note: function a.f is deprecated: use f2 instead
==

[case testKeepFunctionDeprecation]
[case testDeprecatedKeepFunctionDeprecation]
from a import f
f()
import a
Expand All @@ -10632,7 +10632,7 @@ main:1: note: function a.f is deprecated: use f2 instead
main:4: note: function a.f is deprecated: use f2 instead


[case testAddFunctionDeprecationIndirectImport1-only_when_nocache]
[case testDeprecatedAddFunctionDeprecationIndirectImport]
from b import f
f()
import b
Expand All @@ -10649,15 +10649,15 @@ from typing_extensions import deprecated
@deprecated("use f2 instead")
def f() -> int: ...


[builtins fixtures/tuple.pyi]
[out]
==
b.py:1: note: function a.f is deprecated: use f2 instead
main:1: note: function a.f is deprecated: use f2 instead
main:4: note: function a.f is deprecated: use f2 instead
b.py:1: note: function a.f is deprecated: use f2 instead

[case testAddFunctionDeprecationIndirectImport2-only_when_cache]

[case testDeprecatedChangeFunctionDeprecationIndirectImport]
from b import f
f()
import b
Expand All @@ -10667,17 +10667,45 @@ b.f()
from a import f

[file a.py]
from typing_extensions import deprecated
@deprecated("use f1 instead")
def f() -> int: ...

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


[builtins fixtures/tuple.pyi]
[out]
b.py:1: note: function a.f is deprecated: use f1 instead
main:1: note: function a.f is deprecated: use f1 instead
main:4: note: function a.f is deprecated: use f1 instead
==
b.py:1: note: function a.f is deprecated: use f2 instead
main:1: note: function a.f is deprecated: use f2 instead
main:4: note: function a.f is deprecated: use f2 instead

[case testDeprecatedRemoveFunctionDeprecationIndirectImport]
from b import f
f()
import b
b.f()

[file b.py]
from a import f

[file a.py]
from typing_extensions import deprecated
@deprecated("use f1 instead")
def f() -> int: ...

[file a.py.2]
def f() -> int: ...

[builtins fixtures/tuple.pyi]
[out]
b.py:1: note: function a.f is deprecated: use f1 instead
main:1: note: function a.f is deprecated: use f1 instead
main:4: note: function a.f is deprecated: use f1 instead
==

0 comments on commit 09a53d5

Please sign in to comment.