Skip to content

Commit

Permalink
intellij: Final is inferred properly
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Aug 10, 2024
1 parent 80078cc commit 8be017f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions intellij/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## [Unreleased]

## [0.1.4]

### Fixed
- `Final` types infer correctly


## [0.1.3]

### Added
Expand Down
2 changes: 1 addition & 1 deletion intellij/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = org.basedsoft.plugins.basedtyping
pluginName = basedtyping
pluginRepositoryUrl = https://github.com/KotlinIsland/basedtyping
# SemVer format -> https://semver.org
pluginVersion = 0.1.3+242
pluginVersion = 0.1.4

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private class BasedTypingTypeProvider : PyTypeProviderBase() {
override fun getReferenceType(referenceTarget: PsiElement, context: TypeEvalContext, anchor: PsiElement?): Ref<PyType>? {
if (referenceTarget !is PyTargetExpression) return null
val annotation = referenceTarget.annotation?.value ?: return null
return Ref.create(getType(annotation, context))
return Ref.create(getType(annotation, context) ?: return null)
}

override fun getParameterType(param: PyNamedParameter, func: PyFunction, context: TypeEvalContext): Ref<PyType>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ class PyTypeProviderTest : PyTestCase() {
""" exprIs "int"
}

fun `test Final`() {
"""
from typing import Final
expr: Final = 1
""" exprIs "int"
}

private infix fun String.exprIs(expectedType: String) {
myFixture.configureByText(PythonFileType.INSTANCE, this.trimIndent())
val expr = myFixture.findElementByText("expr", PyExpression::class.java)
Expand Down

0 comments on commit 8be017f

Please sign in to comment.