From ca2f7d49193b271b7e89f8a72d9463b61728dff7 Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Fri, 3 Apr 2026 22:22:27 -0400 Subject: [PATCH] Document "Incompatible Import of" Fixes https://github.com/python/mypy/issues/13031 I just copied the relevant test case into here. I think the syntax is intuitive enough that the reader will understand. --- docs/source/error_code_list.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 034c795e71201..91bfe40eb3d29 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -438,6 +438,19 @@ Example: # variable has type "str") [assignment] r.name = 5 +Less obviously, this can also occur when importing, for the same underlying reason: + +.. code-block:: python + + from m1 import * + from m2 import * # E: Incompatible import of "x" (imported name has type "int", local name has type "str") [assignment] + + [file m1.py] + x = '' + + [file m2.py] + x = 1 + .. _code-method-assign: Check that assignment target is not a method [method-assign]