From 23e19847c42d3f900108de65b9d007df507cc09f Mon Sep 17 00:00:00 2001
From: Ivan Levkivskyi <levkivskyi@gmail.com>
Date: Sun, 28 Aug 2022 00:01:35 +0100
Subject: [PATCH 1/2] Ignore partial type in base when inferring/checking

---
 mypy/checker.py                     | 4 +++-
 test-data/unit/check-inference.test | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/mypy/checker.py b/mypy/checker.py
index 415cb0d5cab4..49738cfea279 100644
--- a/mypy/checker.py
+++ b/mypy/checker.py
@@ -2711,7 +2711,7 @@ def get_variable_type_context(self, inferred: Var) -> Type | None:
                 base_type, base_node = self.lvalue_type_from_base(inferred, base)
                 if base_type and not (
                     isinstance(base_node, Var) and base_node.invalid_partial_type
-                ):
+                ) and not isinstance(base_type, PartialType):
                     type_contexts.append(base_type)
         # Use most derived supertype as type context if available.
         if not type_contexts:
@@ -2813,6 +2813,8 @@ def check_compatibility_all_supers(
                     continue
 
                 base_type, base_node = self.lvalue_type_from_base(lvalue_node, base)
+                if isinstance(base_type, PartialType):
+                    base_type = None
 
                 if base_type:
                     assert base_node is not None
diff --git a/test-data/unit/check-inference.test b/test-data/unit/check-inference.test
index ffcd6d8d94dd..26b468342beb 100644
--- a/test-data/unit/check-inference.test
+++ b/test-data/unit/check-inference.test
@@ -3328,3 +3328,12 @@ class C(P, M):
     x = []  # E: Need type annotation for "x" (hint: "x: List[<type>] = ...")
 reveal_type(C.x)  # N: Revealed type is "builtins.list[Any]"
 [builtins fixtures/list.pyi]
+
+[case testNoPartialInSupertypeAsContext]
+class A:
+    args = {}  # E: Need type annotation for "args" (hint: "args: Dict[<type>, <type>] = ...")
+    def f(self) -> None:
+        value = {1: "Hello"}
+        class B(A):
+            args = value
+[builtins fixtures/dict.pyi]

From 652e72636ec9eb75ef0b5956368484e4f6030946 Mon Sep 17 00:00:00 2001
From: Ivan Levkivskyi <levkivskyi@gmail.com>
Date: Sun, 28 Aug 2022 00:40:24 +0100
Subject: [PATCH 2/2] Fix black

---
 mypy/checker.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mypy/checker.py b/mypy/checker.py
index 49738cfea279..106c8e9a0351 100644
--- a/mypy/checker.py
+++ b/mypy/checker.py
@@ -2709,9 +2709,11 @@ def get_variable_type_context(self, inferred: Var) -> Type | None:
         if inferred.info:
             for base in inferred.info.mro[1:]:
                 base_type, base_node = self.lvalue_type_from_base(inferred, base)
-                if base_type and not (
-                    isinstance(base_node, Var) and base_node.invalid_partial_type
-                ) and not isinstance(base_type, PartialType):
+                if (
+                    base_type
+                    and not (isinstance(base_node, Var) and base_node.invalid_partial_type)
+                    and not isinstance(base_type, PartialType)
+                ):
                     type_contexts.append(base_type)
         # Use most derived supertype as type context if available.
         if not type_contexts: