Skip to content

Commit

Permalink
Merge branch 'main-1.x' into python-comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmcdonald3 committed Sep 17, 2024
2 parents 9662934 + dcc45dc commit 5903489
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ public void customizeAfterIntegrations(CustomizeDirective<GenerationContext, Pyt
CodegenUtils.runCommand("python3 " + file, fileManifest.getBaseDir());
}
formatCode(fileManifest);
formatDocstrings(fileManifest);
runMypy(fileManifest);
}

Expand All @@ -352,6 +353,17 @@ private void formatCode(FileManifest fileManifest) {
CodegenUtils.runCommand("python3 -m black . --exclude \"\"", fileManifest.getBaseDir());
}

private void formatDocstrings(FileManifest fileManifest) {
try {
CodegenUtils.runCommand("python3 -m docformatter -h", fileManifest.getBaseDir());
} catch (CodegenException e) {
LOGGER.warning("Unable to find the python package docformatter. Skipping formatting.");
return;
}
LOGGER.info("Running docformatter on generated code");
CodegenUtils.runCommand("python3 -m docformatter --recursive .", fileManifest.getBaseDir());
}

private void runMypy(FileManifest fileManifest) {
try {
CodegenUtils.runCommand("python3 -m mypy -h", fileManifest.getBaseDir());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,6 @@ protected void writeFromDict(boolean isError) {
() -> {
writer.writeDocs(() -> {
writer.write("Creates a $L from a dictionary.\n", shapeName);
writer.write(
writer.formatDocs(
"""
The dictionary is expected to use the modeled shape names rather \
than the parameter names as keys to be mostly compatible with boto3."""
)
);
});

if (shape.members().isEmpty() && !isError) {
Expand Down Expand Up @@ -523,13 +516,6 @@ protected void writeAsDict(boolean isError) {
"Converts the $L to a dictionary.\n",
symbolProvider.toSymbol(shape).getName()
);
writer.write(
writer.formatDocs(
"""
The dictionary uses the modeled shape names rather than the parameter names \
as keys to be mostly compatible with boto3."""
)
);
});

// If there aren't any optional members, it's best to return immediately.
Expand Down

0 comments on commit 5903489

Please sign in to comment.