bazelbuild / rules_python

Bazel Python Rules
https://rules-python.readthedocs.io
Apache License 2.0
538 stars 542 forks source link

fix: keep import path values if Bazel-builtin PyInfo is removed #2415

Closed rickeylev closed 1 week ago

rickeylev commented 1 week ago

The collect_imports() function added import strings from BuiltinPyInfo if it was non-None. However, operator precedence caused the if-else ternary to ignore both list comprehensions (one for PyInfo and one for BuiltinPyInfo) if BuiltinPyInfo was None.

To fix, I rewrote the function as a regular for loop to eliminate the ambiguous looking ternary expression.

Fixes: https://github.com/bazelbuild/rules_python/issues/2414