MCPcopy
hub / github.com/python/mypy / MemberContext

Class MemberContext

mypy/checkmember.py:83–163  ·  view source on GitHub ↗

Information and objects needed to type check attribute access. Look at the docstring of analyze_member_access for more information.

Source from the content-addressed store, hash-verified

81
82
83class MemberContext:
84 """Information and objects needed to type check attribute access.
85
86 Look at the docstring of analyze_member_access for more information.
87 """
88
89 def __init__(
90 self,
91 *,
92 is_lvalue: bool,
93 is_super: bool,
94 is_operator: bool,
95 original_type: Type,
96 context: Context,
97 chk: TypeCheckerSharedApi,
98 self_type: Type | None = None,
99 module_symbol_table: SymbolTable | None = None,
100 no_deferral: bool = False,
101 is_self: bool = False,
102 rvalue: Expression | None = None,
103 suppress_errors: bool = False,
104 preserve_type_var_ids: bool = False,
105 ) -> None:
106 self.is_lvalue = is_lvalue
107 self.is_super = is_super
108 self.is_operator = is_operator
109 self.original_type = original_type
110 self.self_type = self_type or original_type
111 self.context = context # Error context
112 self.chk = chk
113 self.msg = chk.msg
114 self.module_symbol_table = module_symbol_table
115 self.no_deferral = no_deferral
116 self.is_self = is_self
117 if rvalue is not None:
118 assert is_lvalue
119 self.rvalue = rvalue
120 self.suppress_errors = suppress_errors
121 # This attribute is only used to preserve old protocol member access logic.
122 # It is needed to avoid infinite recursion in cases involving self-referential
123 # generic methods, see find_member() for details. Do not use for other purposes!
124 self.preserve_type_var_ids = preserve_type_var_ids
125
126 def named_type(self, name: str) -> Instance:
127 return self.chk.named_type(name)
128
129 def not_ready_callback(self, name: str, context: Context) -> None:
130 self.chk.handle_cannot_determine_type(name, context)
131
132 def fail(self, msg: str) -> None:
133 if not self.suppress_errors:
134 self.msg.fail(msg, self.context)
135
136 def copy_modified(
137 self,
138 *,
139 self_type: Type | None = None,
140 is_lvalue: bool | None = None,

Callers 4

node_type_from_baseMethod · 0.90
find_memberFunction · 0.90
copy_modifiedMethod · 0.85
analyze_member_accessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…