Looks up the given operator and returns the corresponding type, if it exists.
(self, op_name: str, base_type: Type, context: Context)
| 4073 | ) |
| 4074 | |
| 4075 | def lookup_operator(self, op_name: str, base_type: Type, context: Context) -> Type | None: |
| 4076 | """Looks up the given operator and returns the corresponding type, |
| 4077 | if it exists.""" |
| 4078 | |
| 4079 | # This check is an important performance optimization. |
| 4080 | if not has_operator(base_type, op_name): |
| 4081 | return None |
| 4082 | |
| 4083 | with self.msg.filter_errors() as w: |
| 4084 | member = analyze_member_access( |
| 4085 | name=op_name, |
| 4086 | typ=base_type, |
| 4087 | is_lvalue=False, |
| 4088 | is_super=False, |
| 4089 | is_operator=True, |
| 4090 | original_type=base_type, |
| 4091 | context=context, |
| 4092 | chk=self.chk, |
| 4093 | in_literal_context=self.is_literal_context(), |
| 4094 | ) |
| 4095 | return None if w.has_new_errors() else member |
| 4096 | |
| 4097 | def lookup_definer(self, typ: Instance, attr_name: str) -> str | None: |
| 4098 | """Returns the name of the class that contains the actual definition of attr_name. |
no test coverage detected