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

support ellipsis #31

Merged
merged 1 commit into from
Aug 14, 2019
Merged
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
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