Returns True for expressions for which inferred type should not depend on context. Note that this function can still return False for some expressions where inferred type does not depend on context. It only exists for performance optimizations.
(self, rvalue: Expression)
| 4758 | return erase_typevars(fallback) |
| 4759 | |
| 4760 | def simple_rvalue(self, rvalue: Expression) -> bool: |
| 4761 | """Returns True for expressions for which inferred type should not depend on context. |
| 4762 | |
| 4763 | Note that this function can still return False for some expressions where inferred type |
| 4764 | does not depend on context. It only exists for performance optimizations. |
| 4765 | """ |
| 4766 | if isinstance(rvalue, (IntExpr, StrExpr, BytesExpr, FloatExpr, RefExpr)): |
| 4767 | return True |
| 4768 | if isinstance(rvalue, CallExpr): |
| 4769 | if isinstance(rvalue.callee, RefExpr) and isinstance( |
| 4770 | rvalue.callee.node, SYMBOL_FUNCBASE_TYPES |
| 4771 | ): |
| 4772 | typ = rvalue.callee.node.type |
| 4773 | if isinstance(typ, CallableType): |
| 4774 | return not typ.variables |
| 4775 | elif isinstance(typ, Overloaded): |
| 4776 | return not any(item.variables for item in typ.items) |
| 4777 | return False |
| 4778 | |
| 4779 | def infer_rvalue_with_fallback_context( |
| 4780 | self, |
no test coverage detected