Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
unexge committed Jan 5, 2023
1 parent 35d7419 commit 333bbcf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ fun RustType.pythonType(): PythonType =
is RustType.Box -> this.member.pythonType()
is RustType.Dyn -> this.member.pythonType()
is RustType.Opaque -> PythonType.Opaque(this.name, this.namespace)
is RustType.MaybeConstrained -> this.member.pythonType() // TODO: How to handle this?
// TODO(Constraints): How to handle this?
// Revisit as part of https://github.com/awslabs/smithy-rs/issues/2114
is RustType.MaybeConstrained -> this.member.pythonType()
}

/**
Expand Down Expand Up @@ -167,6 +169,6 @@ fun PythonType.render(fullyQualified: Boolean = true): String {
* Renders [PythonType] with proper escaping for Docstrings.
*/
fun PythonType.renderAsDocstring(): String =
this.render().
replace("[", "\\[").
replace("]", "\\]")
this.render()
.replace("[", "\\[")
.replace("]", "\\]")
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ class PyProjectTomlDecorator : ServerCodegenDecorator {
).toMap(),
"tool" to listOfNotNull(
"maturin" to listOfNotNull(
"python-source" to "python"
"python-source" to "python",
).toMap(),
).toMap()
).toMap(),
)
writeWithNoFormatting(TomlWriter().write(config))
}
Expand Down Expand Up @@ -148,7 +148,7 @@ from .$libName import *
__doc__ = $libName.__doc__
if hasattr($libName, "__all__"):
__all__ = $libName.__all__
""".trimIndent()
""".trimIndent(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,18 @@ class PythonApplicationGenerator(
val output = PythonType.Opaque("${operationName}Output", "crate::output")
val context = PythonType.Opaque("Ctx")
val returnType = PythonType.Union(listOf(output, PythonType.Awaitable(output)))
val handler = PythonType.Union(listOf(
PythonType.Callable(
listOf(input, context),
returnType
val handler = PythonType.Union(
listOf(
PythonType.Callable(
listOf(input, context),
returnType,
),
PythonType.Callable(
listOf(input),
returnType,
),
),
PythonType.Callable(
listOf(input),
returnType
)
))
)

rustTemplate(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ internal class PythonTypeInformationGenerationTest {

// Constructor signature
result.shouldContain("/// :param bar str:")
result.shouldContain("/// :param baz typing.Optional[int]:")
result.shouldContain("/// :param baz typing.Optional\\[int\\]:")

// Field types
result.shouldContain("/// :type str:")
result.shouldContain("/// :type typing.Optional[int]:")
result.shouldContain("/// :type typing.Optional\\[int\\]:")
}
}
2 changes: 1 addition & 1 deletion rust-runtime/aws-smithy-http-server-python/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl DateTime {

/// Read 1 date of `format` from `s`, expecting either `delim` or EOF.
///
/// TODO: How do we represent `char` in Python?
/// TODO(PythonTyping): How do we represent `char` in Python?
///
/// :param format Format:
/// :param delim str:
Expand Down

0 comments on commit 333bbcf

Please sign in to comment.