Skip to content

Commit

Permalink
Merge pull request #39 from koxudaxi/fix_no_annotated_fields
Browse files Browse the repository at this point in the history
 fix no annotated fields
  • Loading branch information
koxudaxi committed Aug 16, 2019
2 parents f2cc1b6 + ea654d4 commit 9146fcc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<vendor email="koaxudai@gmail.com">Koudai Aono @koxudaxi</vendor>
<change-notes><![CDATA[
<h2>version 0.0.13</h2>
<p>Features</p>
<p>Features, BugFixes</p>
<ul>
<li>No arguments required for BaseSettings [#] </li>
<li>Fix to check a type of fields without a type-hint [#39] </li>
<li>No arguments required for BaseSettings [#38] </li>
</ul>
<h2>version 0.0.12</h2>
<p>Features</p>
Expand Down
4 changes: 2 additions & 2 deletions src/com/koxudaxi/pydantic/PydanticTypeProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ class PydanticTypeProvider : PyTypeProviderBase() {
val stub = field.stub
val fieldStub = if (stub == null) PydanticFieldStubImpl.create(field) else stub.getCustomStub(PydanticFieldStub::class.java)
if (fieldStub != null && !fieldStub.initValue()) return null
if (fieldStub == null && field.annotationValue == null) return null // skip fields that are not annotated
if (fieldStub == null && field.annotationValue == null && !field.hasAssignedValue()) return null // skip fields that are invalid syntax

val defaultValue = when {
pyClass.isSubclass("pydantic.env_settings.BaseSettings", context) -> ellipsis
else -> getDefaultValueForParameter(field, fieldStub, ellipsis, context)
else -> getDefaultValueForParameter(field, fieldStub, ellipsis, context)
}

return PyCallableParameterImpl.nonPsi(field.name,
Expand Down

0 comments on commit 9146fcc

Please sign in to comment.