Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a087a58

Browse filesBrowse files
authored
Update import map when new modules added (#20271)
Fixes #20209
1 parent 35e843c commit a087a58
Copy full SHA for a087a58

File tree

Expand file treeCollapse file tree

2 files changed

+18
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-0
lines changed
Open diff view settings
Collapse file

‎mypy/server/update.py‎

Copy file name to clipboardExpand all lines: mypy/server/update.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ def restore(ids: list[str]) -> None:
631631

632632
# Find any other modules brought in by imports.
633633
changed_modules = [(st.id, st.xpath) for st in new_modules]
634+
for m in new_modules:
635+
manager.import_map[m.id] = set(m.dependencies + m.suppressed)
634636

635637
# If there are multiple modules to process, only process one of them and return
636638
# the remaining ones to the caller.
Collapse file

‎test-data/unit/fine-grained-modules.test‎

Copy file name to clipboardExpand all lines: test-data/unit/fine-grained-modules.test
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,3 +2244,19 @@ undefined
22442244
a.py:1: error: Cannot find implementation or library stub for module named "foobar"
22452245
a.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
22462246
==
2247+
2248+
[case testDaemonImportMapRefresh]
2249+
# cmd: mypy main.py
2250+
[file main.py]
2251+
[file main.py.2]
2252+
import a.b
2253+
reveal_type(a.b.foo())
2254+
[file a/__init__.pyi]
2255+
[file a/b.pyi]
2256+
import a.c
2257+
def foo() -> a.c.C: ...
2258+
[file a/c.pyi]
2259+
class C: ...
2260+
[out]
2261+
==
2262+
main.py:2: note: Revealed type is "a.c.C"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.