PY-77538 Extract PyPositionalVariadicType marker interface

that indicates types compatible with PyTypeVarTupleType: PyTypeVarTupleType and
PyUnpackedTupleType. It will allow introducing a counterpart interface for types
compatible with PyParamSpecType.

GitOrigin-RevId: 0d5c77dd21d2bc7a21b246cfbd951cdd096918e9
This commit is contained in:
Mikhail Golubev
2024-11-21 11:26:23 +00:00
committed by intellij-monorepo-bot
parent 8b87ae9d16
commit 816845add5
10 changed files with 56 additions and 39 deletions
@@ -0,0 +1,17 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.python.psi.types;
import org.jetbrains.annotations.ApiStatus;
/**
* Two variants of such types described in <a href="https://peps.python.org/pep-0646/">PEP 646 Variadic Generics</a> are
* TypeVarTuples and unpacked tuple types.
*
* @see PyTypeVarTupleType
* @see PyUnpackedTupleType
*/
@ApiStatus.Experimental
public interface PyPositionalVariadicType extends PyVariadicType {
}
@@ -23,5 +23,5 @@ package com.jetbrains.python.psi.types;
* @see <a href="https://peps.python.org/pep-0646/#type-variable-tuples">PEP 646 Variadic Generics</a>
* @see PyUnpackedTupleType
*/
public interface PyTypeVarTupleType extends PyTypeParameterType, PyVariadicType {
public interface PyTypeVarTupleType extends PyTypeParameterType, PyPositionalVariadicType {
}
@@ -17,7 +17,7 @@ import java.util.List;
* @see <a href="https://peps.python.org/pep-0646/#unpacking-tuple-types">PEP 646 Variadic Generics</a>
* @see PyTypeVarTupleType
*/
public interface PyUnpackedTupleType extends PyVariadicType {
public interface PyUnpackedTupleType extends PyPositionalVariadicType {
/**
* Returns types contained inside this unpacked tuple type.
* <p>
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.python.psi.types;
import com.intellij.psi.PsiElement;
@@ -15,13 +15,11 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* A marker interface for type forms that can be "unpacked" into a series of types.
* A marker interface for type forms that can be "unpacked" into a collection of other types, either a nameless series,
* or associated with parameters of a callable type.
* Normally, such constructs cannot be used on their own in type hints, and can appear only inside other generic types.
* Two variants of such types described in <a href="https://peps.python.org/pep-0646/">PEP 646 Variadic Generics</a> are
* TypeVarTuples and unpacked tuple types.
*
* @see PyTypeVarTupleType
* @see PyUnpackedTupleType
* @see PyPositionalVariadicType
*/
@ApiStatus.Experimental
public interface PyVariadicType extends PyType {