Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Set;
import java.util.stream.Collectors;
import software.amazon.smithy.python.codegen.GenerationContext;
import software.amazon.smithy.utils.SmithyInternalApi;
Expand All @@ -15,6 +16,8 @@
*/
@SmithyInternalApi
public final class InitGenerator implements Runnable {
// Set of directories that need __init__.py files
private static final Set<String> PACKAGE_DIRECTORIES = Set.of("src", "tests");

private final GenerationContext context;

Expand All @@ -31,6 +34,7 @@ public void run() {
.stream()
.map(Paths::get)
.filter(path -> !path.getParent().equals(context.fileManifest().getBaseDir()))
.filter(path -> PACKAGE_DIRECTORIES.contains(path.getName(0).toString()))
Copy link
Contributor

@nateprewitt nateprewitt Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.getName(0) in this case is always the first path part rather than a qualified path? e.g. src and not /src or aws-sdk-bedrock-runtime/src?

.collect(Collectors.groupingBy(Path::getParent, Collectors.toSet()));
for (var entry : directories.entrySet()) {
var initPath = entry.getKey().resolve("__init__.py");
Expand Down
Loading