mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-84107 Fix Type Parameters mistakenly reported as unused in PyUnusedLocalInspection
GitOrigin-RevId: 0593c2290aa1c84dde96673297374efef2b27fc3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6639fe14c3
commit
931cf5c4e1
+7
@@ -257,6 +257,13 @@ public final class PyUnusedLocalInspectionVisitor extends PyInspectionVisitor {
|
||||
if (declOwner != null && declOwner != owner) {
|
||||
readsFromInstruction.addAll(ScopeUtil.getElementsOfAccessType(name, declOwner, ReadWriteInstruction.ACCESS.WRITE));
|
||||
}
|
||||
// Type params are not present in CFG
|
||||
else if (owner instanceof PyTypeParameterListOwner typeParameterListOwner &&
|
||||
typeParameterListOwner.getTypeParameterList() != null) {
|
||||
StreamEx.of(typeParameterListOwner.getTypeParameterList().getTypeParameters())
|
||||
.filter(typeParameter -> name.equals(typeParameter.getName()))
|
||||
.forEach(readsFromInstruction::add);
|
||||
}
|
||||
}
|
||||
ControlFlowUtil.iteratePrev(startInstruction, instructions, inst -> {
|
||||
final PsiElement instElement = inst.getElement();
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
from typing import Callable
|
||||
|
||||
def wait_for_condition[T](fn: Callable[..., T]) -> T:
|
||||
return fn()
|
||||
|
||||
def foo[T, U](fn: Callable[..., T]) -> U:
|
||||
return fn()
|
||||
|
||||
def bar[T, <weak_warning descr="Type parameter 'U' is not used">U</weak_warning>](fn: Callable[..., T]) -> T:
|
||||
return fn()
|
||||
|
||||
def baz[<weak_warning descr="Type parameter 'T' is not used">T</weak_warning>, <weak_warning descr="Type parameter 'U' is not used">U</weak_warning>](fn: Callable[..., int]) -> str:
|
||||
return fn()
|
||||
@@ -247,6 +247,11 @@ def test():
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-84107
|
||||
public void testNewStyleTypeParameterInFuncNotMarkedAsUnused() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user