Skip to content

Commit 2e0d85a

Browse files
authored
Merge branch 'master' into move-funcs-checkmember
2 parents a2dee23 + 60f00f3 commit 2e0d85a

File tree

5 files changed

+5
-33
lines changed

5 files changed

+5
-33
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
@@ -1502,7 +1502,6 @@ def check_union_call_expr(self, e: CallExpr, object_type: UnionType, member: str
15021502
is_lvalue=False,
15031503
is_super=False,
15041504
is_operator=False,
1505-
msg=self.msg,
15061505
original_type=object_type,
15071506
chk=self.chk,
15081507
in_literal_context=self.is_literal_context(),
@@ -1590,7 +1589,6 @@ def check_call(
15901589
is_lvalue=False,
15911590
is_super=False,
15921591
is_operator=True,
1593-
msg=self.msg,
15941592
original_type=original_type or callee,
15951593
chk=self.chk,
15961594
in_literal_context=self.is_literal_context(),
@@ -3350,7 +3348,6 @@ def analyze_ordinary_member_access(self, e: MemberExpr, is_lvalue: bool) -> Type
33503348
is_lvalue=is_lvalue,
33513349
is_super=False,
33523350
is_operator=False,
3353-
msg=self.msg,
33543351
original_type=original_type,
33553352
chk=self.chk,
33563353
in_literal_context=self.is_literal_context(),
@@ -3374,7 +3371,6 @@ def analyze_external_member_access(
33743371
is_lvalue=False,
33753372
is_super=False,
33763373
is_operator=False,
3377-
msg=self.msg,
33783374
original_type=base_type,
33793375
chk=self.chk,
33803376
in_literal_context=self.is_literal_context(),
@@ -3869,7 +3865,6 @@ def check_method_call_by_name(
38693865
is_lvalue=False,
38703866
is_super=False,
38713867
is_operator=True,
3872-
msg=self.msg,
38733868
original_type=original_type,
38743869
self_type=base_type,
38753870
chk=self.chk,
@@ -3964,7 +3959,6 @@ def lookup_operator(op_name: str, base_type: Type) -> Type | None:
39643959
is_operator=True,
39653960
original_type=base_type,
39663961
context=context,
3967-
msg=self.msg,
39683962
chk=self.chk,
39693963
in_literal_context=self.is_literal_context(),
39703964
)
@@ -5565,7 +5559,6 @@ def visit_super_expr(self, e: SuperExpr) -> Type:
55655559
original_type=instance_type,
55665560
override_info=base,
55675561
context=e,
5568-
msg=self.msg,
55695562
chk=self.chk,
55705563
in_literal_context=self.is_literal_context(),
55715564
)

mypy/checkmember.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def __init__(
9393
is_operator: bool,
9494
original_type: Type,
9595
context: Context,
96-
msg: MessageBuilder,
9796
chk: mypy.checker.TypeChecker,
9897
self_type: Type | None,
9998
module_symbol_table: SymbolTable | None = None,
@@ -106,8 +105,8 @@ def __init__(
106105
self.original_type = original_type
107106
self.self_type = self_type or original_type
108107
self.context = context # Error context
109-
self.msg = msg
110108
self.chk = chk
109+
self.msg = chk.msg
111110
self.module_symbol_table = module_symbol_table
112111
self.no_deferral = no_deferral
113112
self.is_self = is_self
@@ -121,7 +120,6 @@ def not_ready_callback(self, name: str, context: Context) -> None:
121120
def copy_modified(
122121
self,
123122
*,
124-
messages: MessageBuilder | None = None,
125123
self_type: Type | None = None,
126124
is_lvalue: bool | None = None,
127125
original_type: Type | None = None,
@@ -132,14 +130,11 @@ def copy_modified(
132130
is_operator=self.is_operator,
133131
original_type=self.original_type,
134132
context=self.context,
135-
msg=self.msg,
136133
chk=self.chk,
137134
self_type=self.self_type,
138135
module_symbol_table=self.module_symbol_table,
139136
no_deferral=self.no_deferral,
140137
)
141-
if messages is not None:
142-
mx.msg = messages
143138
if self_type is not None:
144139
mx.self_type = self_type
145140
if is_lvalue is not None:
@@ -157,7 +152,6 @@ def analyze_member_access(
157152
is_lvalue: bool,
158153
is_super: bool,
159154
is_operator: bool,
160-
msg: MessageBuilder,
161155
original_type: Type,
162156
chk: mypy.checker.TypeChecker,
163157
override_info: TypeInfo | None = None,
@@ -196,7 +190,6 @@ def analyze_member_access(
196190
is_operator=is_operator,
197191
original_type=original_type,
198192
context=context,
199-
msg=msg,
200193
chk=chk,
201194
self_type=self_type,
202195
module_symbol_table=module_symbol_table,
@@ -494,7 +487,8 @@ def analyze_member_var_access(
494487
original_type is the type of E in the expression E.var
495488
"""
496489
# It was not a method. Try looking up a variable.
497-
v = lookup_member_var_or_accessor(info, name, mx.is_lvalue)
490+
node = info.get(name)
491+
v = node.node if node else None
498492

499493
mx.chk.warn_deprecated(v, mx.context)
500494

@@ -885,16 +879,6 @@ def expand_self_type_if_needed(
885879
return t
886880

887881

888-
def lookup_member_var_or_accessor(info: TypeInfo, name: str, is_lvalue: bool) -> SymbolNode | None:
889-
"""Find the attribute/accessor node that refers to a member of a type."""
890-
# TODO handle lvalues
891-
node = info.get(name)
892-
if node:
893-
return node.node
894-
else:
895-
return None
896-
897-
898882
def check_self_arg(
899883
functype: FunctionLike,
900884
dispatched_arg_type: Type,

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
)

mypy/stubtest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ def from_overloadedfuncdef(stub: nodes.OverloadedFuncDef) -> Signature[nodes.Arg
858858

859859
all_args: dict[str, list[tuple[nodes.Argument, int]]] = {}
860860
for func in map(_resolve_funcitem_from_decorator, stub.items):
861-
assert func is not None
861+
assert func is not None, "Failed to resolve decorated overload"
862862
args = maybe_strip_cls(stub.name, func.arguments)
863863
for index, arg in enumerate(args):
864864
# For positional-only args, we allow overloads to have different names for the same
@@ -1330,6 +1330,7 @@ def apply_decorator_to_funcitem(
13301330
if (
13311331
decorator.fullname in ("builtins.staticmethod", "abc.abstractmethod")
13321332
or decorator.fullname in mypy.types.OVERLOAD_NAMES
1333+
or decorator.fullname in mypy.types.OVERRIDE_DECORATOR_NAMES
13331334
or decorator.fullname in mypy.types.FINAL_DECORATOR_NAMES
13341335
):
13351336
return func

0 commit comments

Comments
 (0)