cool-easter-32542
12/21/2023, 5:27 PMRust inference parser exhibits some dependency misinterpretation issues when python-infer.string_imports is enabled. This is evident in the following examples:
1. The Rust parser in Pants could not infer dependencies across multiple lines correctly. In the following example, the Rust parser identifies a.b as a dependency, whereas the classic parser correctly discerns `a.b.c.d`:
@mock.patch(
'a.b.'
'c.d',
new=mock.PropertyMock(return_value=0.7))
2. For the string BASE_PATH = 'a.b.', the Rust parser mistakenly treats it as a dependency, unlike the classic parser.
3. In print('retrying...'), the Rust parser incorrectly interprets it as a dependency, while the classic parser does not.
To compare the Rust and classic parsers, the following commands were executed on both MacOS and Linux:
mkdir -p pants_inference
pants --python-infer-no-use-rust-parser peek :: > pants_inference/classic_parser.json
pants --python-infer-use-rust-parser peek :: > pants_inference/rust_parser.json
diff pants_inference/classic_parser.json pants_inference/rust_parser.json
Here is the pants configuration in pants.toml.
[python-infer]
unowned_dependency_behavior = "error"
use_rust_parser = true
string_imports = true # Infer a target's dependencies based on strings that look like dynamic dependencies
Pants version
2.17.0
OS
Both MacOS and Linux.
Additional info
pantsbuild/pants