Skip to content

Commit

Permalink
support ellipsis
Browse files Browse the repository at this point in the history
  • Loading branch information
koxudaxi committed Aug 14, 2019
1 parent fbf777d commit 2d7e9c9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/com/koxudaxi/pydantic/PydanticTypeProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class PydanticTypeProvider : PyTypeProviderBase() {
cls
.findClassAttribute(name, false, context)
?.let {
return Ref.create(getTypeForParameter(it, context)) }
return Ref.create(getTypeForParameter(it, context))
}

for (ancestor in cls.getAncestorClasses(context)) {
ancestor
Expand Down Expand Up @@ -134,7 +135,7 @@ class PydanticTypeProvider : PyTypeProviderBase() {

when {
annotation.qualifier?.text == "Optional" -> return ellipsis
annotation.qualifier?.text == "Union" -> for (child in annotation.children){
annotation.qualifier?.text == "Union" -> for (child in annotation.children) {
if (child is PyTupleExpression) {
for (type in child.children) {
if (type is PyNoneLiteralExpression) {
Expand All @@ -146,7 +147,11 @@ class PydanticTypeProvider : PyTypeProviderBase() {
}
return value
}
field.hasAssignedValue() -> return ellipsis
field.hasAssignedValue() -> {
return if (field.findAssignedValue()!!.text == "...") {
null
} else ellipsis
}
else -> return null
}
} else if (fieldStub.hasDefault() || fieldStub.hasDefaultFactory()) {
Expand Down

0 comments on commit 2d7e9c9

Please sign in to comment.