Skip to content

Commit

Permalink
polish mypy inference for attr.Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasha10 committed Nov 5, 2023
1 parent aa9a970 commit 222c4b5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions omegaconf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,17 @@ def get_attr_data(obj: Any, allow_objects: Optional[bool] = None) -> Dict[str, A
default = attrib.default
if default == attr.NOTHING:
value = MISSING
elif isinstance(default, attr.Factory): # type: ignore
if default.takes_self: # type: ignore
elif isinstance(default, attr.Factory): # type: ignore[arg-type]
assert default is not None
if default.takes_self:
e = ConfigValueError(
"'takes_self' in attrs attributes is not supported\n"
+ f"{name}: {type_str(type_)}"
)
format_and_raise(
node=None, key=None, value=default, cause=e, msg=str(e)
)
value = default.factory() # type: ignore
value = default.factory()
else:
value = default
if is_union_annotation(type_) and not is_supported_union_annotation(type_):
Expand Down

0 comments on commit 222c4b5

Please sign in to comment.