<#19248 `from ..foo import *` glob imports are sil...
# github-notifications
c
#19248 `from ..foo import *` glob imports are silently ignored by Rust parser Issue created by huonw Describe the bug The new Rust parser doesn't seem to understand a 'plain' parent import, like
from ..file1 import *
. It does understand
from ..file1 import func
, though. This reproducer constructs a directory structure like:
Copy code
.
├── pants.toml
└── src
    └── a
        ├── BUILD
        ├── file1.py
        └── file2.py
where
file2.py
has
from .file1 import *
. It runs
pants peek src/a/file2.py
with both the python parser (which shows a dependency on
src/a/file1.py
) and with the Rust parser (which doesn't). Unlike #19173, there's no inference warnings either.
Copy code
cd $(mktemp -d)

cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.17.0rc0"

backend_packages = ["pants.backend.python"]

[python]
interpreter_constraints = [">=3.8"]

[python-infer]
use_rust_parser = false
EOF

# set up the file structure:
mkdir -p src/a
touch src/a/file1.py
echo "from .file1 import *" > src/a/file2.py

echo "python_sources()" > src/a/BUILD

tree .

# OK: with Python parser `"dependencies": ["src/a/file1.py"]`
pants peek src/a/file2.py

# flip to the rust parser
sed -i '' 's/use_rust_parser = false/use_rust_parser = true/' pants.toml

# BUG: with Rust parser `"dependencies": []`
pants peek src/a/file2.py
Pants version 2.17.0rc0 OS macOS Additional info #19173 pantsbuild/pants