diff --git a/CHANGELOG.md b/CHANGELOG.md index 571ee2fe..889a8198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- Support PyCharm 2023.3 [[#840](https://github.com/koxudaxi/pydantic-pycharm-plugin/pull/840)] ## [0.4.9] - 2023-10-12 diff --git a/build.gradle.kts b/build.gradle.kts index 39874935..c2b8eb09 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -96,6 +96,10 @@ tasks { }) } + runPluginVerifier { + ideVersions.set(listOf("PC-2023.3")) + } + // Configure UI tests plugin // Read more: https://github.com/JetBrains/intellij-ui-test-robot runIdeForUiTests { diff --git a/gradle.properties b/gradle.properties index 4c64310c..70d322ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,15 +4,15 @@ pluginGroup = com.koxudaxi.pydantic pluginName = Pydantic pluginRepositoryUrl = https://github.com/koxudaxi/pydantic-pycharm-plugin # SemVer format -> https://semver.org -pluginVersion = 0.4.9 +pluginVersion = 0.4.10 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -pluginSinceBuild = 232 +pluginSinceBuild = 233.11799.241 pluginUntilBuild = 233.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType = PC -platformVersion = 233.9102.128-EAP-SNAPSHOT +platformVersion = 2023.3 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 diff --git a/src/com/koxudaxi/pydantic/PydanticTypeCheckerInspection.kt b/src/com/koxudaxi/pydantic/PydanticTypeCheckerInspection.kt index a38c6291..2941bdea 100644 --- a/src/com/koxudaxi/pydantic/PydanticTypeCheckerInspection.kt +++ b/src/com/koxudaxi/pydantic/PydanticTypeCheckerInspection.kt @@ -103,7 +103,7 @@ class PydanticTypeCheckerInspection : PyTypeCheckerInspection() { private fun analyzeCallee(callSite: PyCallSiteExpression, mapping: PyArgumentsMapping) { val callableType = mapping.callableType ?: return val receiver = callSite.getReceiver(callableType.callable) - val substitutions = PyTypeChecker.unifyReceiverWithParamSpecs(receiver, myTypeEvalContext) + val substitutions = PyTypeChecker.unifyReceiver(receiver, myTypeEvalContext) val mappedParameters = mapping.mappedParameters val cachedParsableTypeMap = mutableMapOf() val cachedAcceptableTypeMap = mutableMapOf() diff --git a/src/com/koxudaxi/pydantic/PydanticTypeProvider.kt b/src/com/koxudaxi/pydantic/PydanticTypeProvider.kt index d7ed09d4..52510c83 100644 --- a/src/com/koxudaxi/pydantic/PydanticTypeProvider.kt +++ b/src/com/koxudaxi/pydantic/PydanticTypeProvider.kt @@ -565,7 +565,7 @@ class PydanticTypeProvider : PyTypeProviderBase() { }?.let { when (genericTypeMap) { null -> it - else -> PyTypeChecker.substitute(it, genericTypeMap, context) + else -> PyTypeChecker.substitute(it, PyTypeChecker.GenericSubstitutions(genericTypeMap), context) } } diff --git a/testData/typeinspection/dynamicModel.py b/testData/typeinspection/dynamicModel.py index 1a2dfc60..66cf12ab 100644 --- a/testData/typeinspection/dynamicModel.py +++ b/testData/typeinspection/dynamicModel.py @@ -8,7 +8,7 @@ class StaticFoobarModel(BaseModel): DynamicFoobarModel(foo='name', bar=123) -DynamicFoobarModel(foo=123, bar='name') +DynamicFoobarModel(foo=123, bar='name') BarModel = create_model( model_name='BarModel', @@ -18,7 +18,7 @@ class StaticFoobarModel(BaseModel): ) BarModel(foo='name', bar=123, apple='green', banana='red') -BarModel(foo=123, bar='name', apple=123, banana=456) +BarModel(foo=123, bar='name', apple=123, banana=456) model_name = 'DynamicBarModel' DynamicBarModel = create_model( @@ -29,12 +29,12 @@ class StaticFoobarModel(BaseModel): ) DynamicBarModel(foo='name', bar=123, apple='green', banana='red') -DynamicBarModel(foo=123, bar='name', apple=123, banana=456) +DynamicBarModel(foo=123, bar='name', apple=123, banana=456) DynamicModifiedBarModel = create_model('DynamicModifiedFoobarModel', foo=(int, ...), bar='abc', __base__=DynamicBarModel) DynamicModifiedBarModel(foo=456, bar='efg', apple='green', banana='red') -DynamicModifiedBarModel(foo='123', bar=456, apple=123, banana=456) +DynamicModifiedBarModel(foo='123', bar=456, apple=123, banana=456) DynamicBrokenModel = create_model( diff --git a/testData/typeinspectionv18/dataclass.py b/testData/typeinspectionv18/dataclass.py index 82ed9c6b..4dbfe83d 100644 --- a/testData/typeinspectionv18/dataclass.py +++ b/testData/typeinspectionv18/dataclass.py @@ -25,10 +25,10 @@ class ChildDataclass(MyDataclass): d: int MyDataclass(a='apple', b=1) -MyDataclass(a=2, b='orange') +MyDataclass(a=2, b='orange') ChildDataclass(a='apple', b=1, c='berry', d=3) -ChildDataclass(a=2, b='orange', c=4, d='cherry') +ChildDataclass(a=2, b='orange', c=4, d='cherry') a: MyDataclass = MyDataclass() diff --git a/testData/typeinspectionv18/dynamicModel.py b/testData/typeinspectionv18/dynamicModel.py index e0535a22..5bf9265b 100644 --- a/testData/typeinspectionv18/dynamicModel.py +++ b/testData/typeinspectionv18/dynamicModel.py @@ -8,7 +8,7 @@ class StaticFoobarModel(BaseModel): DynamicFoobarModel(foo='name', bar=123) -DynamicFoobarModel(foo=123, bar='name') +DynamicFoobarModel(foo=123, bar='name') BarModel = create_model( __model_name='BarModel', @@ -18,7 +18,7 @@ class StaticFoobarModel(BaseModel): ) BarModel(foo='name', bar=123, apple='green', banana='red') -BarModel(foo=123, bar='name', apple=123, banana=456) +BarModel(foo=123, bar='name', apple=123, banana=456) model_name = 'DynamicBarModel' DynamicBarModel = create_model( @@ -29,9 +29,9 @@ class StaticFoobarModel(BaseModel): ) DynamicBarModel(foo='name', bar=123, apple='green', banana='red') -DynamicBarModel(foo=123, bar='name', apple=123, banana=456) +DynamicBarModel(foo=123, bar='name', apple=123, banana=456) DynamicModifiedBarModel = create_model('DynamicModifiedFoobarModel', foo=(int, ...), bar='abc', __base__=DynamicBarModel) DynamicModifiedBarModel(foo=456, bar='efg', apple='green', banana='red') -DynamicModifiedBarModel(foo='123', bar=456, apple=123, banana=456) +DynamicModifiedBarModel(foo='123', bar=456, apple=123, banana=456) diff --git a/testData/typeinspectionv18/genericModel.py b/testData/typeinspectionv18/genericModel.py index a47d35d6..168c6d85 100644 --- a/testData/typeinspectionv18/genericModel.py +++ b/testData/typeinspectionv18/genericModel.py @@ -59,7 +59,7 @@ class ChildClass(BaseClass[int, TypeY], Generic[TypeY, TypeZ]): # Replace TypeY by str ChildClass[str, float](x=1, y='y', z=3.1) -ChildClass[float, bytes](x=b'1', y='y', z=1_3) +ChildClass[float, bytes](x=b'1', y='y', z=1_3) DataT = TypeVar('DataT') @@ -78,7 +78,7 @@ def __concrete_name__(cls: Type[Any], params: Tuple[Type[Any], ...]) -> str: Response[str](data=1) -Response[float](data='a') +Response[float](data='a') T = TypeVar('T') @@ -97,7 +97,7 @@ class OuterT(GenericModel, Generic[T]): OuterT[int](outer=1, nested=nested) nested = InnerT[str](inner='a') -OuterT[int](outer='a', nested=nested) +OuterT[int](outer='a', nested=nested) AT = TypeVar('AT') BT = TypeVar('BT') @@ -116,7 +116,7 @@ class Model(GenericModel, Generic[AT, BT]): typevar_model(a=1, b=1) -typevar_model(a='a', b='a') +typevar_model(a='a', b='a') concrete_model = typevar_model[int] concrete_model(a=1, b=1) @@ -142,7 +142,7 @@ class Model(GenericModel, Generic[CT, DT]): Model[int, int](a=[int], b=[2]) -Model[int, int](a=1, b='2') +Model[int, int](a=1, b='2') class Model(GenericModel, Generic[CT, DT, ET, FT]): a: CT @@ -167,7 +167,7 @@ class Model(GenericModel, Generic[CT]): Model[Union[int, float]](a=1) -Model[Union[int, float]](a='1') +Model[Union[int, float]](a='1') class Model(GenericModel, Generic[CT, DT]): a: CT @@ -178,7 +178,7 @@ def x(b: ET) -> ET: Model[x(int), Optional[x(int)]](a=1, b=2) -Model[x(int), Optional[x(int)]](a='1', b='2') +Model[x(int), Optional[x(int)]](a='1', b='2') class Model(GenericModel, Generic[CT, DT]): a: CT @@ -188,7 +188,7 @@ class Model(GenericModel, Generic[CT, DT]): Model[y, Optional[y]](a=1, b=2) -Model[y, Optional[y]](a='1', b='2') +Model[y, Optional[y]](a='1', b='2') class Model(GenericModel, Generic[CT, DT, ET, FT, aaaaaaaaaa]): @@ -196,4 +196,4 @@ class Model(GenericModel, Generic[CT, DT, ET, FT, aaaaaaaaaa]): b: List[aaaaa] c: Dict[ET, aaaaaaaa] -Model[aaaaaaaaaa, List[aaaaaa], Tuple[aaaaaaaaaa], Type[aaaaaaaaaaa]](a=int, b=[2], c={'c': 3}) \ No newline at end of file +Model[aaaaaaaaaa, List[aaaaaa], Tuple[aaaaaaaaaa], Type[aaaaaaaaaaa]](a=int, b=[2], c={'c': 3}) \ No newline at end of file diff --git a/testData/typeinspectionv18/sqlModel.py b/testData/typeinspectionv18/sqlModel.py index 57073cde..46b3b0b2 100644 --- a/testData/typeinspectionv18/sqlModel.py +++ b/testData/typeinspectionv18/sqlModel.py @@ -15,4 +15,4 @@ class Hero(SQLModel, table=True): hero_4 = Hero(secret_name="test") -hero_5 = Hero(name=123, secret_name=456, age="abc") \ No newline at end of file +hero_5 = Hero(name=123, secret_name=456, age="abc") \ No newline at end of file diff --git a/testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt b/testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt index 17f6228b..393b0f0d 100644 --- a/testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt +++ b/testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt @@ -24,6 +24,7 @@ open class PydanticCompletionTest : PydanticTestCase() { "__slots__", "__text_signature__", "__weakrefoffset__", + "__type_params__", "Ellipsis", "EnvironmentError", "IOError",