Skip to content

Commit 8be017f

Browse files
committed
intellij: Final is inferred properly
1 parent 80078cc commit 8be017f

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

intellij/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
## [Unreleased]
66

7+
## [0.1.4]
8+
9+
### Fixed
10+
- `Final` types infer correctly
11+
12+
713
## [0.1.3]
814

915
### Added

intellij/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = org.basedsoft.plugins.basedtyping
44
pluginName = basedtyping
55
pluginRepositoryUrl = https://github.com/KotlinIsland/basedtyping
66
# SemVer format -> https://semver.org
7-
pluginVersion = 0.1.3+242
7+
pluginVersion = 0.1.4
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 233

intellij/src/main/kotlin/org/basedsoft/plugins/basedtyping/BasedTypingTypeProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private class BasedTypingTypeProvider : PyTypeProviderBase() {
1616
override fun getReferenceType(referenceTarget: PsiElement, context: TypeEvalContext, anchor: PsiElement?): Ref<PyType>? {
1717
if (referenceTarget !is PyTargetExpression) return null
1818
val annotation = referenceTarget.annotation?.value ?: return null
19-
return Ref.create(getType(annotation, context))
19+
return Ref.create(getType(annotation, context) ?: return null)
2020
}
2121

2222
override fun getParameterType(param: PyNamedParameter, func: PyFunction, context: TypeEvalContext): Ref<PyType>? {

intellij/src/test/kotlin/org/basedsoft/plugins/basedtyping/TestBasedTypeProvider.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ class PyTypeProviderTest : PyTestCase() {
6565
""" exprIs "int"
6666
}
6767

68+
fun `test Final`() {
69+
"""
70+
from typing import Final
71+
expr: Final = 1
72+
""" exprIs "int"
73+
}
74+
6875
private infix fun String.exprIs(expectedType: String) {
6976
myFixture.configureByText(PythonFileType.INSTANCE, this.trimIndent())
7077
val expr = myFixture.findElementByText("expr", PyExpression::class.java)

0 commit comments

Comments
 (0)