<#18401 attrs module mapping needs to be updated?>...
# github-notifications
q
#18401 attrs module mapping needs to be updated? Issue created by smsearcy Describe the bug Pants fails to resolve the dependency for
import attrs
with the following error, when
attrs
is listed in
requirements.txt
and
import attr
works:
Copy code
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:
Copy code
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