quaint-telephone-89068
03/03/2023, 10:34 PMimport attrs with the following error, when attrs is listed in requirements.txt and import attr works:
14:19:42.52 [WARN] Pants cannot infer owners for the following imports in the target helloworld/main.py:lib:
* attrs (line: 4)
The attrs class now provides two import packages (as of v21.3.0): attr and attrs. Thus, I think the DEFAULT_MODULE_MAPPING for attrs in src/python/pants/backend/python/dependency_inference/default_module_mapping.py needs to be updated to include both. I was able to workaround the issue by adding the following directive to the BUILD file:
python_requirement(
name="attrs",
requirements=["attrs>=21.3.0"],
modules=["attrs"],
)
Pants version
2.15.0
OS
Ubuntu Linux (WSL).
Additional info
I was able to replicate the issue by cloning https://github.com/pantsbuild/example-python and making the changes published in this gist.
pantsbuild/pants