Skip to content

Conversation

Robbie-Palmer
Copy link

Summary

Fixes issue where packages listed in ignore_pkg_list were still generating import statements, causing compilation errors when the imported packages don't exist or shouldn't be imported.

Problem

When using ignore_pkg_list to exclude certain packages from code generation, the system would still attempt to generate import statements for cross-package references, leading to:

  • Import errors for non-existent packages
  • Unwanted dependencies on packages that should be ignored
  • Compilation failures in generated Python code

Solution

Modified FileDescriptorProtoToCode._add_other_module_pkg to check if a package is in ignore_pkg_list before generating import statements. The fix allows type references to remain in the generated code while properly skipping the import generation.

Changes

  • Core fix: Added check in FileDescriptorProtoToCode._add_other_module_pkg to return early if other_fd.package is in self.config.ignore_pkg_list
  • Test coverage: Added test following existing project patterns - happy to adjust the test approach based on maintainer feedback

When a field references a message from a package listed in ignore_pkg_list,
skip generating relative imports to avoid importing non-existent p2p files.
This allows ignore_pkg_list to work correctly for cross-package references
while relying on customer_import_set for type resolution.
Add test proto files and test case to validate that packages in ignore_pkg_list
do not generate import statements while still allowing type references.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant