Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving sibling modules with absolute imports #1029

Merged
merged 6 commits into from
Jan 31, 2023
Merged

Conversation

linzhp
Copy link
Contributor

@linzhp linzhp commented Jan 28, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

py_test and py_binary unconditionally depends on py_library in the same package. In order to do that, the Gazelle plugin introduce an virtual import to identify the py_library target.

What is the new behavior?

With the capability of resolving sibling modules introduced in #1027, we can resolve py_library as needed in py_test and py_binary, and we no longer need any virtual imports or id for py_library targets. This simplifies the logic.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@linzhp linzhp requested a review from f0rmiga as a code owner January 28, 2023 19:16
@linzhp linzhp mentioned this pull request Jan 28, 2023
12 tasks
@linzhp
Copy link
Contributor Author

linzhp commented Jan 30, 2023

Ready for review, but the CI is affected by https://github.com/orgs/community/discussions/45830

"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/emirpasic/gods/sets/treeset"
godsutils "github.com/emirpasic/gods/utils"
"path/filepath"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unnecessary and wrong change, we keep standard lib imports at the top.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was changed by my GoLand and I didn't notice.

":__test__",
":generated_test_entrypoint",
],
deps = [":__test__"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may be a breaking change.

@f0rmiga f0rmiga merged commit 9fc7cfa into bazelbuild:main Jan 31, 2023
f0rmiga added a commit that referenced this pull request Feb 1, 2023
f0rmiga added a commit that referenced this pull request Feb 1, 2023
This reverts commit 9fc7cfa.

Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
f0rmiga added a commit that referenced this pull request Feb 1, 2023
Revert "Resolving sibling modules with absolute imports (#1029)"

This reverts commit 9fc7cfa.

Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
f0rmiga pushed a commit that referenced this pull request Feb 2, 2023
* Resolving sibling modules with absolute imports

* unconditionally importing conftest

* handle from statements

* adding tests

* adding readme for the new test case

Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
f0rmiga added a commit that referenced this pull request Feb 3, 2023
ianpegg-bc pushed a commit to ianpegg-bc/rules_python that referenced this pull request May 12, 2023
* Resolving sibling modules with absolute imports

* unconditionally importing conftest

* handle from statements

* adding tests

* adding readme for the new test case
ianpegg-bc pushed a commit to ianpegg-bc/rules_python that referenced this pull request May 12, 2023
…1035)

Revert "Resolving sibling modules with absolute imports (bazelbuild#1029)"

This reverts commit 9fc7cfa.

Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
ianpegg-bc pushed a commit to ianpegg-bc/rules_python that referenced this pull request May 12, 2023
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.

None yet

2 participants