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

formatting: run pre-commit on all files #2236

Merged
merged 3 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand All @@ -20,7 +20,7 @@ repos:
files: ^.*$
pass_filenames: false
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v1.6.1
rev: v2.5.0
hooks:
- id: pretty-format-kotlin
args: [--autofix, --ktlint-version, 0.46.1]
Expand Down
2 changes: 1 addition & 1 deletion aws/SDK_CHANGELOG.next.json
Original file line number Diff line number Diff line change
Expand Up @@ -774,4 +774,4 @@
}
],
"aws-sdk-model": []
}
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects.forEach {

it.the<JacocoPluginExtension>().apply {
toolVersion = "0.8.8"
reportsDirectory.set(file("${buildDir}/jacoco-reports"))
reportsDirectory.set(file("$buildDir/jacoco-reports"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ class InstantiatorTest {
fun `generate maps of maps`() {
val data = Node.parse(
"""
{
"k1": { "map": {} },
"k2": { "map": { "k3": {} } },
"k3": { }
}
""",
{
"k1": { "map": {} },
"k2": { "map": { "k3": {} } },
"k3": { }
}
""",
)
val sut = Instantiator(
symbolProvider,
Expand All @@ -254,11 +254,11 @@ class InstantiatorTest {
}
rust(
"""
assert_eq!(result.len(), 3);
assert_eq!(result.get("k1").unwrap().map.as_ref().unwrap().len(), 0);
assert_eq!(result.get("k2").unwrap().map.as_ref().unwrap().len(), 1);
assert_eq!(result.get("k3").unwrap().map, None);
""",
assert_eq!(result.len(), 3);
assert_eq!(result.get("k1").unwrap().map.as_ref().unwrap().len(), 0);
assert_eq!(result.get("k2").unwrap().map.as_ref().unwrap().len(), 1);
assert_eq!(result.get("k3").unwrap().map, None);
""",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private sealed class UnsupportedConstraintMessageKind {
fun intoLogMessage(ignoreUnsupportedConstraints: Boolean): LogMessage {
fun buildMessage(intro: String, willSupport: Boolean, trackingIssue: String, canBeIgnored: Boolean = true): String {
var msg = """
$intro
$intro
This is not supported in the smithy-rs server SDK."""
if (willSupport) {
msg += """
Expand Down Expand Up @@ -161,8 +161,8 @@ fun validateOperationsWithConstrainedInputHaveValidationExceptionAttached(
LogMessage(
Level.SEVERE,
"""
Operation ${it.shape.id} takes in input that is constrained
(https://awslabs.github.io/smithy/2.0/spec/constraint-traits.html), and as such can fail with a
Operation ${it.shape.id} takes in input that is constrained
(https://awslabs.github.io/smithy/2.0/spec/constraint-traits.html), and as such can fail with a
validation exception. You must model this behavior in the operation shape in your model file.
""".trimIndent().replace("\n", "") +
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators
*/

fun rustDocsConstrainedTypeEpilogue(typeName: String) = """
This is a constrained type because its corresponding modeled Smithy shape has one or more
[constraint traits]. Use [`$typeName::try_from`] to construct values of this type.
This is a constrained type because its corresponding modeled Smithy shape has one or more
[constraint traits]. Use [`$typeName::try_from`] to construct values of this type.

[constraint traits]: https://awslabs.github.io/smithy/1.0/spec/core/constraint-traits.html
[constraint traits]: https://awslabs.github.io/smithy/1.0/spec/core/constraint-traits.html
"""

fun rustDocsTryFromMethod(typeName: String, inner: String) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ fun generateFallbackCodeToDefaultValue(
// storing the result in a `OnceCell` that could be reused.
writer.rustTemplate(
"""
.unwrap_or_else(||
#{DefaultValue:W}
.try_into()
.expect("this check should have failed at generation time; please file a bug report under https://github.com/awslabs/smithy-rs/issues")
)
""",
.unwrap_or_else(||
#{DefaultValue:W}
.try_into()
.expect("this check should have failed at generation time; please file a bug report under https://github.com/awslabs/smithy-rs/issues")
)
""",
"DefaultValue" to defaultValue,
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,29 @@ internal class DeriveEqAndHashSymbolMetadataProviderTest {
input: TestInputOutput
output: TestInputOutput
}

operation StreamingOperation {
input: StreamingOperationInputOutput
output: StreamingOperationInputOutput
}

operation EventStreamOperation {
input: EventStreamOperationInputOutput
output: EventStreamOperationInputOutput
}

structure EventStreamOperationInputOutput {
@httpPayload
@required
union: StreamingUnion
}

structure StreamingOperationInputOutput {
@httpPayload
@required
blobStream: BlobStream
}

@streaming
blob BlobStream

Expand All @@ -68,14 +68,14 @@ internal class DeriveEqAndHashSymbolMetadataProviderTest {
containsFloat: ContainsFloat
containsDouble: ContainsDouble
containsDocument: ContainsDocument

hasList: HasList
hasListWithMap: HasListWithMap
hasMap: HasMap

eqAndHashStruct: EqAndHashStruct
}

structure EqAndHashStruct {
blob: Blob
boolean: Boolean
Expand All @@ -86,27 +86,27 @@ internal class DeriveEqAndHashSymbolMetadataProviderTest {
long: Long
enum: Enum
timestamp: Timestamp

list: List
union: EqAndHashUnion

// bigInteger: BigInteger
// bigDecimal: BigDecimal
}

list List {
member: String
}

list ListWithMap {
member: Map
}

map Map {
key: String
value: String
}

union EqAndHashUnion {
blob: Blob
boolean: Boolean
Expand All @@ -117,51 +117,51 @@ internal class DeriveEqAndHashSymbolMetadataProviderTest {
long: Long
enum: Enum
timestamp: Timestamp

list: List
}

@streaming
union StreamingUnion {
eqAndHashStruct: EqAndHashStruct
}

structure HasFloat {
float: Float
}

structure HasDouble {
double: Double
}

structure HasDocument {
document: Document
}

structure HasList {
list: List
}

structure HasListWithMap {
list: ListWithMap
}

structure HasMap {
map: Map
}

structure ContainsFloat {
hasFloat: HasFloat
}

structure ContainsDouble {
hasDouble: HasDouble
}

structure ContainsDocument {
containsDocument: HasDocument
}

enum Enum {
DIAMOND
CLUB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ internal class ValidateUnsupportedConstraintsAreNotUsedTest {

// Asserts the exact message, to ensure the formatting is appropriate.
validationResult.messages[0].message shouldBe """Operation test#TestOperation takes in input that is constrained (https://awslabs.github.io/smithy/2.0/spec/constraint-traits.html), and as such can fail with a validation exception. You must model this behavior in the operation shape in your model file.
```smithy
use smithy.framework#ValidationException
```smithy
Velfi marked this conversation as resolved.
Show resolved Hide resolved
use smithy.framework#ValidationException

operation TestOperation {
...
errors: [..., ValidationException] // <-- Add this.
}
operation TestOperation {
...
errors: [..., ValidationException] // <-- Add this.
}
```"""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ConstrainedMapGeneratorTest {
TestCase(
"""
namespace test

$trait
map ConstrainedMap {
key: String,
Expand Down Expand Up @@ -129,13 +129,13 @@ class ConstrainedMapGeneratorTest {
fun `type should not be constructible without using a constructor`() {
val model = """
namespace test

@length(min: 1, max: 69)
map ConstrainedMap {
key: String,
value: String
}
""".asSmithyModel().let(ShapesReachableFromOperationInputTagger::transform)
""".asSmithyModel().let(ShapesReachableFromOperationInputTagger::transform)
val constrainedMapShape = model.lookup<MapShape>("test#ConstrainedMap")

val writer = RustWriter.forModule(ModelsModule.name)
Expand Down
2 changes: 1 addition & 1 deletion rust-runtime/aws-smithy-http-server-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ENTRYPOINT [ "/var/lang/bin/python3.8" ]
CMD [ "/app.py" ]
```

See [https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base)
See [https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base)
for more details on building your custom image.

<!-- anchor_start:footer -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ifndef HAS_MATURIN
$(error "maturin is not available; please install it via 'pip install maturin' or 'cargo install maturin'")
endif

# Note on `--compatibility linux`: Maturin by default uses `manylinux_x_y` but it is not supported
# Note on `--compatibility linux`: Maturin by default uses `manylinux_x_y` but it is not supported
# by our current CI version (3.7.10), we can drop `--compatibility linux` when we switch to higher Python version.
# For more detail: https://github.com/pypa/manylinux
build-wheel: ensure-maturin codegen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ assert headers.get("host") == None
assert len(headers) == 2

assert set(headers.items()) == set([
("content-length", "45"),
("content-length", "45"),
("content-encoding", "application/json")
])
"#
Expand Down