Skip to content

Commit cee0e3d

Browse files
authored
Merge pull request #400 from koxudaxi/support_pycharm_2021.3
Support PyCharm 2021.3
2 parents b3684b2 + 2132802 commit cee0e3d

13 files changed

Lines changed: 31 additions & 22 deletions

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.2
3333
with:
3434
ide-versions: |
35-
pycharmPC:2021.1
35+
pycharmPC:2021.3
3636
pycharmPC:LATEST-EAP-SNAPSHOT
3737
- name: setup python
3838
uses: actions/setup-python@v1

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515

1616
intellij {
1717
pluginName = project.name
18-
version = "2021.2.2"
18+
version = "2021.3"
1919
type = "PC"
2020
updateSinceUntilBuild = false
2121
downloadSources = true
@@ -24,8 +24,8 @@ intellij {
2424

2525

2626
patchPluginXml {
27-
sinceBuild = "212.5284.19"
28-
untilBuild = "212.*"
27+
sinceBuild = "213.5744.248"
28+
untilBuild = "213.*"
2929
}
3030

3131

resources/META-INF/plugin.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<idea-plugin url="https://github.com/koxudaxi/pydantic-pycharm-plugin" require-restart="true">
22
<id>com.koxudaxi.pydantic</id>
33
<name>Pydantic</name>
4-
<version>0.3.8</version>
4+
<version>0.3.9</version>
55
<vendor email="koaxudai@gmail.com">Koudai Aono @koxudaxi</vendor>
66
<change-notes><![CDATA[
7+
<h2>version 0.3.9</h2>
8+
<p>Features</p>
9+
<ul>
10+
<li>Support PyCharm 2021.3 [#400]</li>
11+
</ul>
712
<h2>version 0.3.8</h2>
813
<p>Features</p>
914
<ul>

src/com/koxudaxi/pydantic/PydanticCacheService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class PydanticCacheService {
6666
}
6767

6868
private fun getInstance(project: Project): PydanticCacheService {
69-
return ServiceManager.getService(project, PydanticCacheService::class.java)
69+
return project.getService(PydanticCacheService::class.java)
7070
}
7171
}
7272

src/com/koxudaxi/pydantic/PydanticConfigService.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.koxudaxi.pydantic
22

33
import com.intellij.codeInspection.ProblemHighlightType
44
import com.intellij.openapi.components.PersistentStateComponent
5-
import com.intellij.openapi.components.ServiceManager
65
import com.intellij.openapi.components.State
76
import com.intellij.openapi.components.Storage
87
import com.intellij.openapi.project.Project

src/com/koxudaxi/pydantic/PydanticInitializer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class PydanticInitializer : StartupActivity {
8282
}
8383
}
8484

85-
} catch (e: AlreadyDisposedException) {
85+
} catch (_: AlreadyDisposedException) {
8686
}
8787
}
8888
}
@@ -179,7 +179,7 @@ class PydanticInitializer : StartupActivity {
179179
DumbService.getInstance(project).smartInvokeLater {
180180
try {
181181
initializeFileLoader(project)
182-
} catch (e: AlreadyDisposedException) {
182+
} catch (_: AlreadyDisposedException) {
183183
}
184184
}
185185
}

src/com/koxudaxi/pydantic/PydanticInsertArgumentsQuickFix.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class PydanticInsertArgumentsQuickFix(private val onlyRequired: Boolean) : Local
4040

4141
override fun startInWriteAction(): Boolean = true
4242

43-
fun runFix(
43+
private fun runFix(
4444
project: Project,
4545
file: PsiFile,
4646
originalElement: PsiElement,

src/com/koxudaxi/pydantic/PydanticInspection.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.jetbrains.python.psi.impl.PyTargetExpressionImpl
1313
import com.jetbrains.python.psi.resolve.PyResolveContext
1414
import com.jetbrains.python.psi.types.PyClassType
1515
import com.jetbrains.python.psi.types.PyClassTypeImpl
16+
import com.jetbrains.python.psi.types.TypeEvalContext
1617

1718

1819
class PydanticInspection : PyInspection() {
@@ -21,10 +22,10 @@ class PydanticInspection : PyInspection() {
2122
holder: ProblemsHolder,
2223
isOnTheFly: Boolean,
2324
session: LocalInspectionToolSession,
24-
): PsiElementVisitor = Visitor(holder, session)
25+
): PsiElementVisitor = Visitor(holder, PyInspectionVisitor.getContext(session))
2526

26-
inner class Visitor(holder: ProblemsHolder, session: LocalInspectionToolSession) :
27-
PyInspectionVisitor(holder, session) {
27+
inner class Visitor(holder: ProblemsHolder, context: TypeEvalContext) :
28+
PyInspectionVisitor(holder, context) {
2829

2930
val pydanticConfigService = PydanticConfigService.getInstance(holder.project)
3031

src/com/koxudaxi/pydantic/PydanticPackageManagerListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class PydanticPackageManagerListener : PyPackageManager.Listener {
3030
runWriteAction {
3131
try {
3232
pydanticStub.delete(this)
33-
} catch (e: java.io.IOException) {
33+
} catch (_: java.io.IOException) {
3434
} finally {
3535
pydanticStub.refresh(true, true) {
3636
clearVersion(sdk)

src/com/koxudaxi/pydantic/PydanticTypeCheckerInspection.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.intellij.openapi.util.Key
88
import com.intellij.psi.PsiElementVisitor
99
import com.jetbrains.python.codeInsight.typing.matchingProtocolDefinitions
1010
import com.jetbrains.python.documentation.PythonDocumentationProvider
11+
import com.jetbrains.python.inspections.PyInspectionVisitor
1112
import com.jetbrains.python.inspections.PyTypeCheckerInspection
1213
import com.jetbrains.python.psi.PyCallExpression
1314
import com.jetbrains.python.psi.PyCallExpression.PyArgumentsMapping
@@ -27,11 +28,11 @@ class PydanticTypeCheckerInspection : PyTypeCheckerInspection() {
2728
if (LOG.isDebugEnabled) {
2829
session.putUserData(TIME_KEY, System.nanoTime())
2930
}
30-
return Visitor(holder, session)
31+
return Visitor(holder, PyInspectionVisitor.getContext(session))
3132
}
3233

33-
class Visitor(holder: ProblemsHolder?, session: LocalInspectionToolSession) :
34-
PyTypeCheckerInspection.Visitor(holder, session) {
34+
class Visitor(holder: ProblemsHolder?, context: TypeEvalContext) :
35+
PyTypeCheckerInspection.Visitor(holder, context) {
3536

3637
val pydanticConfigService = PydanticConfigService.getInstance(holder!!.project)
3738

@@ -103,7 +104,7 @@ class PydanticTypeCheckerInspection : PyTypeCheckerInspection() {
103104
private fun analyzeCallee(callSite: PyCallSiteExpression, mapping: PyArgumentsMapping) {
104105
val callableType = mapping.callableType ?: return
105106
val receiver = callSite.getReceiver(callableType.callable)
106-
val substitutions = PyTypeChecker.unifyReceiver(receiver, myTypeEvalContext)
107+
val substitutions = PyTypeChecker.unifyReceiverWithParamSpecs(receiver, myTypeEvalContext)
107108
val mappedParameters = mapping.mappedParameters
108109
val cachedParsableTypeMap = mutableMapOf<PyType, PyType?>()
109110
val cachedAcceptableTypeMap = mutableMapOf<PyType, PyType?>()
@@ -162,7 +163,7 @@ class PydanticTypeCheckerInspection : PyTypeCheckerInspection() {
162163
private fun matchParameterAndArgument(
163164
parameterType: PyType?,
164165
argumentType: PyType?,
165-
substitutions: Map<PyGenericType, PyType>,
166+
substitutions: PyTypeChecker.GenericSubstitutions,
166167
): Boolean {
167168
return PyTypeChecker.match(parameterType,
168169
argumentType,

0 commit comments

Comments
 (0)