Skip to content

Commit 60f00f3

Browse files
authored
Do not pass message builder to analyze_member_access (#18818)
This is a pure refactoring so I am not waiting for a review.
1 parent 045a6d8 commit 60f00f3

File tree

4 files changed

+1
-21
lines changed

4 files changed

+1
-21
lines changed

mypy/checker.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,6 @@ def extract_callable_type(self, inner_type: Type | None, ctx: Context) -> Callab
781781
is_lvalue=False,
782782
is_super=False,
783783
is_operator=True,
784-
msg=self.msg,
785784
original_type=inner_type,
786785
chk=self,
787786
)
@@ -4736,7 +4735,6 @@ def check_member_assignment(
47364735
original_type=instance_type,
47374736
context=context,
47384737
self_type=None,
4739-
msg=self.msg,
47404738
chk=self,
47414739
)
47424740
get_type = analyze_descriptor_access(attribute_type, mx, assignment=True)
@@ -6746,7 +6744,6 @@ def replay_lookup(new_parent_type: ProperType) -> Type | None:
67466744
is_lvalue=False,
67476745
is_super=False,
67486746
is_operator=False,
6749-
msg=self.msg,
67506747
original_type=new_parent_type,
67516748
chk=self,
67526749
in_literal_context=False,
@@ -8044,7 +8041,6 @@ def has_valid_attribute(self, typ: Type, name: str) -> bool:
80448041
is_lvalue=False,
80458042
is_super=False,
80468043
is_operator=False,
8047-
msg=self.msg,
80488044
original_type=typ,
80498045
chk=self,
80508046
# This is not a real attribute lookup so don't mess with deferring nodes.

mypy/checkexpr.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,6 @@ def check_union_call_expr(self, e: CallExpr, object_type: UnionType, member: str
15051505
is_lvalue=False,
15061506
is_super=False,
15071507
is_operator=False,
1508-
msg=self.msg,
15091508
original_type=object_type,
15101509
chk=self.chk,
15111510
in_literal_context=self.is_literal_context(),
@@ -1593,7 +1592,6 @@ def check_call(
15931592
is_lvalue=False,
15941593
is_super=False,
15951594
is_operator=True,
1596-
msg=self.msg,
15971595
original_type=original_type or callee,
15981596
chk=self.chk,
15991597
in_literal_context=self.is_literal_context(),
@@ -3353,7 +3351,6 @@ def analyze_ordinary_member_access(self, e: MemberExpr, is_lvalue: bool) -> Type
33533351
is_lvalue=is_lvalue,
33543352
is_super=False,
33553353
is_operator=False,
3356-
msg=self.msg,
33573354
original_type=original_type,
33583355
chk=self.chk,
33593356
in_literal_context=self.is_literal_context(),
@@ -3377,7 +3374,6 @@ def analyze_external_member_access(
33773374
is_lvalue=False,
33783375
is_super=False,
33793376
is_operator=False,
3380-
msg=self.msg,
33813377
original_type=base_type,
33823378
chk=self.chk,
33833379
in_literal_context=self.is_literal_context(),
@@ -3872,7 +3868,6 @@ def check_method_call_by_name(
38723868
is_lvalue=False,
38733869
is_super=False,
38743870
is_operator=True,
3875-
msg=self.msg,
38763871
original_type=original_type,
38773872
self_type=base_type,
38783873
chk=self.chk,
@@ -3967,7 +3962,6 @@ def lookup_operator(op_name: str, base_type: Type) -> Type | None:
39673962
is_operator=True,
39683963
original_type=base_type,
39693964
context=context,
3970-
msg=self.msg,
39713965
chk=self.chk,
39723966
in_literal_context=self.is_literal_context(),
39733967
)
@@ -5568,7 +5562,6 @@ def visit_super_expr(self, e: SuperExpr) -> Type:
55685562
original_type=instance_type,
55695563
override_info=base,
55705564
context=e,
5571-
msg=self.msg,
55725565
chk=self.chk,
55735566
in_literal_context=self.is_literal_context(),
55745567
)

mypy/checkmember.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def __init__(
9595
is_operator: bool,
9696
original_type: Type,
9797
context: Context,
98-
msg: MessageBuilder,
9998
chk: mypy.checker.TypeChecker,
10099
self_type: Type | None,
101100
module_symbol_table: SymbolTable | None = None,
@@ -108,8 +107,8 @@ def __init__(
108107
self.original_type = original_type
109108
self.self_type = self_type or original_type
110109
self.context = context # Error context
111-
self.msg = msg
112110
self.chk = chk
111+
self.msg = chk.msg
113112
self.module_symbol_table = module_symbol_table
114113
self.no_deferral = no_deferral
115114
self.is_self = is_self
@@ -123,7 +122,6 @@ def not_ready_callback(self, name: str, context: Context) -> None:
123122
def copy_modified(
124123
self,
125124
*,
126-
messages: MessageBuilder | None = None,
127125
self_type: Type | None = None,
128126
is_lvalue: bool | None = None,
129127
original_type: Type | None = None,
@@ -134,14 +132,11 @@ def copy_modified(
134132
is_operator=self.is_operator,
135133
original_type=self.original_type,
136134
context=self.context,
137-
msg=self.msg,
138135
chk=self.chk,
139136
self_type=self.self_type,
140137
module_symbol_table=self.module_symbol_table,
141138
no_deferral=self.no_deferral,
142139
)
143-
if messages is not None:
144-
mx.msg = messages
145140
if self_type is not None:
146141
mx.self_type = self_type
147142
if is_lvalue is not None:
@@ -159,7 +154,6 @@ def analyze_member_access(
159154
is_lvalue: bool,
160155
is_super: bool,
161156
is_operator: bool,
162-
msg: MessageBuilder,
163157
original_type: Type,
164158
chk: mypy.checker.TypeChecker,
165159
override_info: TypeInfo | None = None,
@@ -198,7 +192,6 @@ def analyze_member_access(
198192
is_operator=is_operator,
199193
original_type=original_type,
200194
context=context,
201-
msg=msg,
202195
chk=chk,
203196
self_type=self_type,
204197
module_symbol_table=module_symbol_table,

mypy/checkpattern.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,6 @@ def visit_class_pattern(self, o: ClassPattern) -> PatternType:
598598
is_lvalue=False,
599599
is_super=False,
600600
is_operator=False,
601-
msg=self.msg,
602601
original_type=typ,
603602
chk=self.chk,
604603
)
@@ -664,7 +663,6 @@ def visit_class_pattern(self, o: ClassPattern) -> PatternType:
664663
is_lvalue=False,
665664
is_super=False,
666665
is_operator=False,
667-
msg=self.msg,
668666
original_type=new_type,
669667
chk=self.chk,
670668
)

0 commit comments

Comments
 (0)