Skip to content

Commit

Permalink
Fix removing python class fields on auto-completion (#62)
Browse files Browse the repository at this point in the history
* Fix removing fields on non-subclasses of pydantic.BaseModel and
pydantic.dataclasses.dataclass

* fix history

* add testdata
  • Loading branch information
koxudaxi committed Sep 3, 2019
1 parent 8103b86 commit d238f50
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<idea-plugin url="https://github.com/koxudaxi/pydantic-pycharm-plugin">
<id>com.koxudaxi.pydantic</id>
<name>Pydantic</name>
<version>0.0.16</version>
<version>0.0.17</version>
<vendor email="koaxudai@gmail.com">Koudai Aono @koxudaxi</vendor>
<change-notes><![CDATA[
<h2>version 0.0.17</h2>
<p>BugFixes</p>
<ul>
<li>Fix removing fields on non-subclasses of pydantic.BaseModel and pydantic.dataclasses.dataclass [#62] </li>
</ul>
<h2>version 0.0.16</h2>
<p>Features, BugFixes</p>
<ul>
Expand Down
2 changes: 2 additions & 0 deletions src/com/koxudaxi/pydantic/PydanticCompletionContributor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class PydanticCompletionContributor : CompletionContributor() {
pyClass: PyClass, typeEvalContext: TypeEvalContext,
excludes: HashSet<String>? = null) {

if (!isPydanticModel(pyClass)) return

val fieldElements: HashSet<String> = HashSet()

pyClass.getAncestorClasses(typeEvalContext)
Expand Down
13 changes: 13 additions & 0 deletions testData/completion/pythonClass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from builtins import *
from pydantic import BaseModel

class B:
hij: str

class A:
abc: str
cde: str
efg: str


A.<caret>
10 changes: 10 additions & 0 deletions testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ open class PydanticCompletionTest : PydanticTestCase() {
)
}

fun testPythonClass() {
doFieldTest(
listOf(
Pair("abc", "A"),
Pair("cde", "A"),
Pair("efg", "A")
)
)
}

fun testField() {
doFieldTest(
listOf(
Expand Down

0 comments on commit d238f50

Please sign in to comment.