Skip to content

fix(bazel): use Label() for deps in py_itf_unittest#118

Merged
AlexanderLanin merged 1 commit into
eclipse-score:mainfrom
etas-contrib:fix/itf-pip-label-resolution
Jun 23, 2026
Merged

fix(bazel): use Label() for deps in py_itf_unittest#118
AlexanderLanin merged 1 commit into
eclipse-score:mainfrom
etas-contrib:fix/itf-pip-label-resolution

Conversation

@clanghans

Copy link
Copy Markdown
Contributor

Summary

The py_itf_unittest macro passes "@score_itf//:itf" and "@itf_pip//pytest_mock" as string labels in the deps list of py_test. In Bazel's bzlmod, string labels inside legacy (def-based) macros are resolved in the caller's repository context, not the defining module's. This means @itf_pip is looked up in the downstream consumer's repo, where it does not exist.

The fix wraps both labels with Label(), which is evaluated at .bzl load time and resolves in score_itf's module context, where itf_pip is always defined.

This is consistent with how pytest_bootstrap and pytest_config are already handled in the same file (lines 33-35).

Problem

Any downstream module that uses py_itf_unittest fails at analysis time:

ERROR: no such package '@@[unknown repo 'itf_pip' requested from @@]//pytest_mock':
  The repository '@@[unknown repo 'itf_pip']' could not be resolved:
  No repository visible as '@itf_pip' from main repository

The only workaround is for every consumer to add use_repo(pip, "itf_pip") to their own MODULE.bazel, leaking an internal implementation detail of score_itf into all downstream modules.

Benefits

  • Downstream consumers no longer need to know about @itf_pip. The pip hub name is an internal detail of score_itf. Consumers should only need bazel_dep(name = "score_itf", ...) to use any public macro.

  • Consistent with the rest of the file. pytest_bootstrap and pytest_config already use Label(). The deps list was the only place still using raw strings for cross-module references.

  • No behavioral change for score_itf's own tests. Label("@itf_pip//...") resolves to the same target within score_itf as the string "@itf_pip//..." does today. The fix only changes resolution behavior when the macro is called from a different module.

String labels in legacy macros resolve in the caller's repo
context, making @itf_pip invisible to downstream consumers.
Label() resolves in the defining module's context instead.

@a-zw a-zw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@clanghans clanghans marked this pull request as ready for review June 19, 2026 06:45
@nick-hildebrant-etas nick-hildebrant-etas removed their request for review June 22, 2026 06:38
@AlexanderLanin

Copy link
Copy Markdown
Member

LGTM and it seems trivial, so I'm merging.

@AlexanderLanin AlexanderLanin added this pull request to the merge queue Jun 23, 2026
Merged via the queue into eclipse-score:main with commit 528cfc1 Jun 23, 2026
7 checks passed
@AlexanderLanin AlexanderLanin deleted the fix/itf-pip-label-resolution branch June 23, 2026 09:03
@github-project-automation github-project-automation Bot moved this from Backlog to Done in TST - Testing Community Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants