diff --git a/python/python-psi-api/src/com/jetbrains/python/psi/PyCallable.java b/python/python-psi-api/src/com/jetbrains/python/psi/PyCallable.java index dff63636a8a4..134f0d36ba20 100644 --- a/python/python-psi-api/src/com/jetbrains/python/psi/PyCallable.java +++ b/python/python-psi-api/src/com/jetbrains/python/psi/PyCallable.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.python.psi; import com.jetbrains.python.ast.PyAstCallable; @@ -33,6 +33,13 @@ public interface PyCallable extends PyAstCallable, PyTypedElement, PyQualifiedNa @NotNull List getParameters(@NotNull TypeEvalContext context); + /** + * Returns the return type of the callable independent of a call site. + */ + default PyType getReturnType(@NotNull TypeEvalContext context) { + return context.getReturnType(this); + } + /** * Returns the return type of the callable independent of a call site. */ diff --git a/python/python-psi-api/src/com/jetbrains/python/psi/PyClass.java b/python/python-psi-api/src/com/jetbrains/python/psi/PyClass.java index 016427e14be9..008a66884570 100644 --- a/python/python-psi-api/src/com/jetbrains/python/psi/PyClass.java +++ b/python/python-psi-api/src/com/jetbrains/python/psi/PyClass.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.python.psi; import com.intellij.psi.PsiElement; @@ -375,8 +375,8 @@ public interface PyClass * @param context eval context * @return {@link PyType} casted if it has right type */ - @Nullable - PyClassLikeType getType(@NotNull TypeEvalContext context); + @Override + @Nullable PyClassLikeType getType(@NotNull TypeEvalContext context); @Override default @Nullable PyStringLiteralExpression getDocStringExpression() { diff --git a/python/python-psi-api/src/com/jetbrains/python/psi/PyTypedElement.java b/python/python-psi-api/src/com/jetbrains/python/psi/PyTypedElement.java index 91d681e960c4..2350e89ef4c2 100644 --- a/python/python-psi-api/src/com/jetbrains/python/psi/PyTypedElement.java +++ b/python/python-psi-api/src/com/jetbrains/python/psi/PyTypedElement.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.python.psi; import com.jetbrains.python.ast.PyAstTypedElement; @@ -26,6 +12,10 @@ import org.jetbrains.annotations.Nullable; * */ public interface PyTypedElement extends PyAstTypedElement, PyElement { + default @Nullable PyType getType(@NotNull TypeEvalContext context) { + return context.getType(this); + } + @Nullable PyType getType(@NotNull TypeEvalContext context, @NotNull TypeEvalContext.Key key); }