Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fields module name for pydantic v1 #71

Merged
merged 4 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.20</version>
<version>0.0.21</version>
<vendor email="koaxudai@gmail.com">Koudai Aono @koxudaxi</vendor>
<change-notes><![CDATA[
<h2>version 0.0.21</h2>
<p>BugFixes</p>
<ul>
<li>Fix fields module name for pydantic v1 [#67] </li>
</ul>
<h2>version 0.0.20</h2>
<p>Features, BugFixes</p>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion src/com/koxudaxi/pydantic/Pydantic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const val BASE_MODEL_Q_NAME = "pydantic.main.BaseModel"
const val DATA_CLASS_Q_NAME = "pydantic.dataclasses.dataclass"
const val VALIDATOR_Q_NAME = "pydantic.validator"
const val SCHEMA_Q_NAME = "pydantic.schema.Schema"
const val FIELD_Q_NAME = "pydantic.field.Field"
const val FIELD_Q_NAME = "pydantic.fields.Field"
const val BASE_SETTINGS_Q_NAME = "pydantic.env_settings.BaseSettings"

internal fun getPyClassByPyKeywordArgument(pyKeywordArgument: PyKeywordArgument, context: TypeEvalContext): PyClass? {
Expand Down
22 changes: 22 additions & 0 deletions testData/completion/fieldField.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from builtins import *
from pydantic import BaseModel, Field

def get_alias():
return 'alias_c_id'
b_id = 'alias_b_id'
class A(BaseModel):
abc: str = Field(...)
cde = Field(str('abc'))
efg = Field(default=str('abc'))
hij = Field(default=...)
a_id: str = Field(..., alias='alias_a_id')
b_id: str = Field(..., alias=b_id)
c_id: str = Field(..., alias=get_alias())
d_id: str = Field(..., alias=)
e_id: str = Field(..., alias=broken)
f_id: str = Field(..., alias=123)
g_id: str = get_alias()
class B(A):
hij: str

A().<caret>
2 changes: 1 addition & 1 deletion testData/mock/pydantic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .main import BaseModel
from .class_validators import validator
from .schema import Schema
from .field import Field
from .fields import Field
from .env_settings import BaseSettings
File renamed without changes.
19 changes: 19 additions & 0 deletions testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,25 @@ open class PydanticCompletionTest : PydanticTestCase() {
)
}

fun testFieldField() {
doFieldTest(
listOf(
Pair("a_id","str A"),
Pair("abc", "str A"),
Pair("b_id","str A"),
Pair("c_id","str A"),
Pair("cde", "str=str('abc') A"),
Pair("d_id", "str A"),
Pair("e_id", "str A"),
Pair("efg", "str=str('abc') A"),
Pair("f_id", "str A"),
Pair("g_id", "str=get_alias() A"),
Pair("hij", "Any A"),
Pair("___slots__", "BaseModel")
)
)
}

fun testClassMethodCls() {
doFieldTest(
listOf(
Expand Down