PsiElement (PsiElement expression, PyExpression newExpression, IntroduceOperation operation) { if (PsiTreeUtil.getParentOfType(expression, ScopeOwner.class) instanceof PyFile) { return super.replaceExpression(expression, newExpression, operation); } return PyReplaceExpressionUtil.replaceExpression(expression, newExpression); }