From 6c3a0f0337a96cb017a1cd4e4770510ec8dc06e0 Mon Sep 17 00:00:00 2001 From: Koudai Aono Date: Sat, 21 Sep 2019 01:34:16 +0900 Subject: [PATCH 1/4] fix fields moduels name for pydantic v1 --- src/com/koxudaxi/pydantic/Pydantic.kt | 2 +- testData/mock/pydantic/{field.py => fields.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename testData/mock/pydantic/{field.py => fields.py} (100%) diff --git a/src/com/koxudaxi/pydantic/Pydantic.kt b/src/com/koxudaxi/pydantic/Pydantic.kt index fffe7f33..51613dc5 100644 --- a/src/com/koxudaxi/pydantic/Pydantic.kt +++ b/src/com/koxudaxi/pydantic/Pydantic.kt @@ -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? { diff --git a/testData/mock/pydantic/field.py b/testData/mock/pydantic/fields.py similarity index 100% rename from testData/mock/pydantic/field.py rename to testData/mock/pydantic/fields.py From 3392c41991c30b1e71d0b489adf13a17865fff96 Mon Sep 17 00:00:00 2001 From: Koudai Aono Date: Sat, 21 Sep 2019 01:39:54 +0900 Subject: [PATCH 2/4] update history --- resources/META-INF/plugin.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 2a06703d..71979766 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -1,9 +1,14 @@ com.koxudaxi.pydantic Pydantic - 0.0.20 + 0.0.21 Koudai Aono @koxudaxi version 0.0.21 +

BugFixes

+
    +
  • Fix fields module name for pydantic v1 [#67]
  • +

version 0.0.20

Features, BugFixes

    From 849fbb587865654bd13a3929b5b3c9af3e07931c Mon Sep 17 00:00:00 2001 From: Koudai Aono Date: Sat, 21 Sep 2019 02:00:15 +0900 Subject: [PATCH 3/4] fix mock --- testData/mock/pydantic/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testData/mock/pydantic/__init__.py b/testData/mock/pydantic/__init__.py index d2c32924..bd37e06e 100644 --- a/testData/mock/pydantic/__init__.py +++ b/testData/mock/pydantic/__init__.py @@ -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 \ No newline at end of file From 929134c54ccd34ac4a0190f7a8b317938beb3d8e Mon Sep 17 00:00:00 2001 From: Koudai Aono Date: Sat, 21 Sep 2019 02:07:48 +0900 Subject: [PATCH 4/4] add unittest --- testData/completion/fieldField.py | 22 +++++++++++++++++++ .../pydantic/PydanticCompletionTest.kt | 19 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 testData/completion/fieldField.py diff --git a/testData/completion/fieldField.py b/testData/completion/fieldField.py new file mode 100644 index 00000000..bc199fbf --- /dev/null +++ b/testData/completion/fieldField.py @@ -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(). \ No newline at end of file diff --git a/testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt b/testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt index e46d4db9..eb27dfb6 100644 --- a/testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt +++ b/testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt @@ -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(