Skip to content

Commit

Permalink
Use kw-only args for member access booleans (#17975)
Browse files Browse the repository at this point in the history
Gets hard to know what's what at call site
  • Loading branch information
hauntsaninja committed Oct 18, 2024
1 parent a5e9b0b commit 2485bed
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 45 deletions.
8 changes: 4 additions & 4 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7520,10 +7520,10 @@ def has_valid_attribute(self, typ: Type, name: str) -> bool:
name,
typ,
TempNode(AnyType(TypeOfAny.special_form)),
False,
False,
False,
self.msg,
is_lvalue=False,
is_super=False,
is_operator=False,
msg=self.msg,
original_type=typ,
chk=self,
# This is not a real attribute lookup so don't mess with deferring nodes.
Expand Down
32 changes: 16 additions & 16 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,10 +1497,10 @@ def check_union_call_expr(self, e: CallExpr, object_type: UnionType, member: str
member,
typ,
e,
False,
False,
False,
self.msg,
is_lvalue=False,
is_super=False,
is_operator=False,
msg=self.msg,
original_type=object_type,
chk=self.chk,
in_literal_context=self.is_literal_context(),
Expand Down Expand Up @@ -3293,10 +3293,10 @@ def analyze_ordinary_member_access(self, e: MemberExpr, is_lvalue: bool) -> Type
e.name,
original_type,
e,
is_lvalue,
False,
False,
self.msg,
is_lvalue=is_lvalue,
is_super=False,
is_operator=False,
msg=self.msg,
original_type=original_type,
chk=self.chk,
in_literal_context=self.is_literal_context(),
Expand All @@ -3317,10 +3317,10 @@ def analyze_external_member_access(
member,
base_type,
context,
False,
False,
False,
self.msg,
is_lvalue=False,
is_super=False,
is_operator=False,
msg=self.msg,
original_type=base_type,
chk=self.chk,
in_literal_context=self.is_literal_context(),
Expand Down Expand Up @@ -3800,10 +3800,10 @@ def check_method_call_by_name(
method,
base_type,
context,
False,
False,
True,
self.msg,
is_lvalue=False,
is_super=False,
is_operator=True,
msg=self.msg,
original_type=original_type,
chk=self.chk,
in_literal_context=self.is_literal_context(),
Expand Down
35 changes: 18 additions & 17 deletions mypy/checkmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class MemberContext:

def __init__(
self,
*,
is_lvalue: bool,
is_super: bool,
is_operator: bool,
Expand Down Expand Up @@ -126,16 +127,16 @@ def copy_modified(
original_type: Type | None = None,
) -> MemberContext:
mx = MemberContext(
self.is_lvalue,
self.is_super,
self.is_operator,
self.original_type,
self.context,
self.msg,
self.chk,
self.self_type,
self.module_symbol_table,
self.no_deferral,
is_lvalue=self.is_lvalue,
is_super=self.is_super,
is_operator=self.is_operator,
original_type=self.original_type,
context=self.context,
msg=self.msg,
chk=self.chk,
self_type=self.self_type,
module_symbol_table=self.module_symbol_table,
no_deferral=self.no_deferral,
)
if messages is not None:
mx.msg = messages
Expand All @@ -152,11 +153,11 @@ def analyze_member_access(
name: str,
typ: Type,
context: Context,
*,
is_lvalue: bool,
is_super: bool,
is_operator: bool,
msg: MessageBuilder,
*,
original_type: Type,
chk: mypy.checker.TypeChecker,
override_info: TypeInfo | None = None,
Expand Down Expand Up @@ -190,12 +191,12 @@ def analyze_member_access(
are not available via the type object directly)
"""
mx = MemberContext(
is_lvalue,
is_super,
is_operator,
original_type,
context,
msg,
is_lvalue=is_lvalue,
is_super=is_super,
is_operator=is_operator,
original_type=original_type,
context=context,
msg=msg,
chk=chk,
self_type=self_type,
module_symbol_table=module_symbol_table,
Expand Down
16 changes: 8 additions & 8 deletions mypy/checkpattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,10 @@ def visit_class_pattern(self, o: ClassPattern) -> PatternType:
"__match_args__",
typ,
o,
False,
False,
False,
self.msg,
is_lvalue=False,
is_super=False,
is_operator=False,
msg=self.msg,
original_type=typ,
chk=self.chk,
)
Expand Down Expand Up @@ -660,10 +660,10 @@ def visit_class_pattern(self, o: ClassPattern) -> PatternType:
keyword,
narrowed_type,
pattern,
False,
False,
False,
self.msg,
is_lvalue=False,
is_super=False,
is_operator=False,
msg=self.msg,
original_type=new_type,
chk=self.chk,
)
Expand Down

0 comments on commit 2485bed

Please sign in to comment.