File tree Expand file tree Collapse file tree 4 files changed +18
-4
lines changed
main/kotlin/space/whitememory/pythoninlayparams/types/hints
test/kotlin/space/whitememory/pythoninlayparams Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 66
77### Fixed
88- Incorrect ` Literal ` behavior with type hints
9+ - ` set[] ` type hint were causing exceptions when declared explicitly
910
1011## [ 0.3.1] - 2022-10-02
1112### Fixed
Original file line number Diff line number Diff line change @@ -4,9 +4,7 @@ package space.whitememory.pythoninlayparams.types.hints
44
55import com.intellij.psi.PsiElement
66import com.jetbrains.python.PyNames
7- import com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider
87import com.jetbrains.python.psi.PyElement
9- import com.jetbrains.python.psi.PyFunction
108import com.jetbrains.python.psi.PyLambdaExpression
119import com.jetbrains.python.psi.types.*
1210
Original file line number Diff line number Diff line change @@ -264,14 +264,16 @@ enum class HintResolver {
264264
265265 if (assignmentValue !is PyCallExpression ) return true
266266
267+ if (typeAnnotation is PyNoneType ) return true
268+
267269 val resolvedClass = PyCallExpressionHelper .resolveCalleeClass(assignmentValue) ? : return true
268270
269271 if (! collectionNames.contains(resolvedClass.name)) {
270272 return resolvedClass.name != typeAnnotation?.name
271273 }
272274
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()
275277 }
276278 },
277279
Original file line number Diff line number Diff line change @@ -183,6 +183,19 @@ class PythonVariableTypesTest : PythonAbstractInlayHintsTestCase() {
183183 """ .trimIndent()
184184 )
185185
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+
186199 private fun doTest (text : String ) {
187200 testProvider(
188201 " foo.py" ,
You can’t perform that action at this time.
0 commit comments