Skip to content

fix(ty): unconditionally include main workspace bin directory in import search paths#916

Open
udaya2899 wants to merge 2 commits into
aspect-build:mainfrom
udaya2899:udaya2899/ty-fix-bin-dir
Open

fix(ty): unconditionally include main workspace bin directory in import search paths#916
udaya2899 wants to merge 2 commits into
aspect-build:mainfrom
udaya2899:udaya2899/ty-fix-bin-dir

Conversation

@udaya2899

Copy link
Copy Markdown

This PR unconditionally adds ctx.bin_dir.path to import_paths for ty aspect.

Why?

Currently, lint/ty.bzl only populates import search paths from dep[PyInfo].imports or via dep.label.workspace_root (for external workspaces).

For standard generated targets in the main workspace (like a standard py_proto_library or py_grpc_library generated from .proto sources):

  1. They do not specify an explicit imports attribute in their PyInfo provider.
  2. workspace_root evaluates to "" (empty string).

This doesn't let ty to resolve generated files' import paths that don't have an imports attr.

  error[unresolved-import]: Import 'foo.bar.proto_name_py2' could not be resolved

Changes are visible to end-users: No

Test plan

  • New test cases added

Unconditionally initialize 'import_paths' with 'ctx.bin_dir.path' so that generated files from the main workspace are correctly resolved.

Without this, for generated dependencies belonging to the main workspace, 'dep.label.workspace_root' evaluates to empty, meaning they are completely skipped from the import search path inclusion. As a result, the static type checker 'ty' is unable to find generated dependencies (such as proto/gRPC _pb2/pb2_grpc files in the main workspace) and throws unresolved-import errors:

  error[unresolved-import]: Import 'foo.bar.my_proto_pb2' could not be resolved
@CLAassistant

CLAassistant commented Jun 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@udaya2899 udaya2899 changed the title fix(ty): unconditionally include main workspace bin directory in import search paths fix(ty): unconditionally include main workspace bin directory in import search paths Jun 18, 2026
@udaya2899

Copy link
Copy Markdown
Author

Friendly ping @jbedard

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.

2 participants