File tree 4 files changed +18
-4
lines changed
main/kotlin/space/whitememory/pythoninlayparams/types/hints
test/kotlin/space/whitememory/pythoninlayparams
4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 6
6
7
7
### Fixed
8
8
- Incorrect ` Literal ` behavior with type hints
9
+ - ` set[] ` type hint were causing exceptions when declared explicitly
9
10
10
11
## [ 0.3.1] - 2022-10-02
11
12
### Fixed
Original file line number Diff line number Diff line change @@ -4,9 +4,7 @@ package space.whitememory.pythoninlayparams.types.hints
4
4
5
5
import com.intellij.psi.PsiElement
6
6
import com.jetbrains.python.PyNames
7
- import com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider
8
7
import com.jetbrains.python.psi.PyElement
9
- import com.jetbrains.python.psi.PyFunction
10
8
import com.jetbrains.python.psi.PyLambdaExpression
11
9
import com.jetbrains.python.psi.types.*
12
10
Original file line number Diff line number Diff line change @@ -264,14 +264,16 @@ enum class HintResolver {
264
264
265
265
if (assignmentValue !is PyCallExpression ) return true
266
266
267
+ if (typeAnnotation is PyNoneType ) return true
268
+
267
269
val resolvedClass = PyCallExpressionHelper .resolveCalleeClass(assignmentValue) ? : return true
268
270
269
271
if (! collectionNames.contains(resolvedClass.name)) {
270
272
return resolvedClass.name != typeAnnotation?.name
271
273
}
272
274
273
- return typeAnnotation?.isBuiltin == true
274
- && (typeAnnotation as PyCollectionType ) .elementTypes.filterNotNull().isNotEmpty()
275
+ val collectionType = ( typeAnnotation as ? PyCollectionType ) ? : return false
276
+ return collectionType.isBuiltin && collectionType .elementTypes.filterNotNull().isNotEmpty()
275
277
}
276
278
},
277
279
Original file line number Diff line number Diff line change @@ -183,6 +183,19 @@ class PythonVariableTypesTest : PythonAbstractInlayHintsTestCase() {
183
183
""" .trimIndent()
184
184
)
185
185
186
+ fun testIterableHints () = doTest(
187
+ """
188
+ item_set<# [: [set [ str ]]] #> = set()
189
+ x<# [: None] #> = item_set.add("1")
190
+
191
+ explicit_item_set: set[str] = set()
192
+ y<# [: None] #> = explicit_item_set.add("1")
193
+
194
+ unclear_item_set: set = set()
195
+ z<# [: None] #> = unclear_item_set.add("1")
196
+ """ .trimIndent()
197
+ )
198
+
186
199
private fun doTest (text : String ) {
187
200
testProvider(
188
201
" foo.py" ,
You can’t perform that action at this time.
0 commit comments