mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-44714 PyTypedDictInspection: don't register problem with None
Fix false positive with None as TypedDict value type close #1452 GitOrigin-RevId: 7c02d8928f2e9ef3612aaf69d6daeb5a1b71cb95
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a43a6b5ba5
commit
1fdb8235e9
+1
-1
@@ -278,7 +278,7 @@ class PyTypedDictInspection : PyInspection() {
|
||||
* Checks that [expression] with [strType] name is a type
|
||||
*/
|
||||
private fun checkValueIsAType(expression: PyExpression?, strType: String?) {
|
||||
if (expression !is PyReferenceExpression && expression !is PySubscriptionExpression || strType == null) {
|
||||
if (expression !is PyReferenceExpression && expression !is PySubscriptionExpression && expression !is PyNoneLiteralExpression || strType == null) {
|
||||
registerProblem(expression, PyPsiBundle.message("INSP.typeddict.value.must.be.type"), ProblemHighlightType.WEAK_WARNING)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -300,6 +300,16 @@ public class PyTypedDictInspectionTest extends PyInspectionTestCase {
|
||||
" return movie[<warning descr=\"TypedDict key must be a string literal; expected one of ('name', 'year')\">key</warning>]"));
|
||||
}
|
||||
|
||||
// PY-44714
|
||||
public void testNoneAsType() {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.getLatest(),
|
||||
() -> doTestByText("from typing import TypedDict\n" +
|
||||
"class X(TypedDict):\n" +
|
||||
" n: None\n" +
|
||||
"Y = TypedDict('Y', {'n': None})\n"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user