You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the docs, by default a class wrapped with chex.dataclass can be indexed, because the dataclass becomes compatible with collections.abc.Mapping (because mappable_dataclass=True).
However, mypy doesn't seem to understand this. For example:
importchex@chex.dataclassclassContainer:
foo: floatc=Container(foo=1.)
d=c.foo# OK.e=c['foo'] # error: Value of type "Container" is not indexable [index]
Looking at the code, it seems that this is related to methods such as __getitem__ that are added dynamically with setattr which mypy doesn't recognise.
Any ideas how to go around this apart for (i) explicitly silencing the error (ii) using a different method of accessing the variables?
Keep up the good work!
Hylke
The text was updated successfully, but these errors were encountered:
According to the docs, by default a class wrapped with
chex.dataclass
can be indexed, because the dataclass becomes compatible withcollections.abc.Mapping
(becausemappable_dataclass=True
).However, mypy doesn't seem to understand this. For example:
Looking at the code, it seems that this is related to methods such as
__getitem__
that are added dynamically withsetattr
which mypy doesn't recognise.Any ideas how to go around this apart for (i) explicitly silencing the error (ii) using a different method of accessing the variables?
Keep up the good work!
Hylke
The text was updated successfully, but these errors were encountered: