Closed gummz closed 1 year ago
Yes, it does: https://www.attrs.org/en/stable/api.html#attrs.has
Do you have another thing providing attr in your environment, or, are you using an old version of attr?
The former. Result of pip show attr
:
Name: attr
Version: 0.3.2
Summary: Simple decorator to set attributes of target function or class in a DRY way.
Home-page: https://github.com/denis-ryzhkov/attr
Author: Denis Ryzhkov
Author-email: denisr@denisr.com
License: MIT
Location: /home/ghb/anaconda3/envs/aisc/lib/python3.9/site-packages
Requires:
Required-by:
I see here https://pypi.org/project/attrs/ that, in their example, the import is referred to as attrs. But in _utils.py
it's referred to as attr.
@gummz you want pip install attrs
, not pip install attr
.
I may be mistaken but I don't think that is the solution. There is a package called attr which is different from attrs. On attrs' project page, it is seen that they import it like import attrs
, but you import it as import attr
, which leads to a conflict with the package called attr, without the s.
I put pip install attr
to reproduce the problem, which is that there is a conflict between attr and attrs, if you import attrs as import attr
.
The output of your pip show attr
points to this package on pypi.
That is not the right package. You need this package on pypi.
See also the attrs.org documentation, which says python -m pip install attrs
is the way to go.
Both the attr
and the attrs
packages on pypi install a module called attr
.
Ah ok that makes sense. Is there anything to do about a package conflict like this? I need attr for my project. To get it to work I had to return false instead of calling attr.has().
Oh dear. Unfortunately, Python doesn't have great support for resolving such conflicts in the module namespace. I think this is a type of dependency hell.
To summarize the issue, the OmegaConf source has hardcoded a dependency on a module named attr
, and you're using an unrelated package that also exports an attr
module.
I can't think of any solution besides forking one of the packages involved and doing some renaming:
attr
package and rename the exposed module to e.g. attr2
, so that omegaconf won't accidentally import it.omegaconf
and change the import statements in omegaconf so that it will not try to import or use the attr
module.
Describe the bug A clear and concise description of what the bug is.
To Reproduce Please provide a minimal repro. This can include a small Python file, and potentially a few small config files. If you have more than one file you can attach a zip file with everything to the issue.
repro.py:
configs_repro/config.yaml:
test: True
Expected behavior A clear and concise description of what you expected to happen.
A successful initialization of my configs, and a returned namespace object.
Additional context