Skip to content

Commit

Permalink
fix instantiate overloads for Any (#260)
Browse files Browse the repository at this point in the history
Co-authored-by: rsokl <ryan.soklaski@ll.mit.edu>
  • Loading branch information
rsokl and rsokl authored Apr 15, 2022
1 parent 9d10306 commit 9fa5d0b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/hydra_zen/_hydra_overloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
F = TypeVar("F", bound=Callable[..., Any])


class _TightBind: # pragma: no cover
...


@overload
def instantiate(
config: _TightBind, *args: Any, **kwargs: Any
) -> Any: # pragma: no cover
...


@overload
def instantiate(
config: InstOrType[ConfigPath], *args: Any, **kwargs: Any
Expand Down
10 changes: 10 additions & 0 deletions tests/annotations/declarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
make_custom_builds_fn,
mutable_value,
)
from hydra_zen.structured_configs._value_conversion import ConfigComplex, ConfigPath
from hydra_zen.typing import (
Builds,
HydraPartialBuilds,
Expand Down Expand Up @@ -1012,3 +1013,12 @@ def check_make_custom_builds_overloads(boolean: bool):
make_custom_builds_fn(populate_full_signature=boolean, zen_partial=boolean),
expected_text="FullBuilds | PBuilds | StdBuilds",
)


def check_instantiate_overrides(
any_: Any, complex_: ConfigComplex, path_: ConfigPath, dataclass_: DataClass_
):
reveal_type(instantiate(any_), expected_text="Any")
reveal_type(instantiate(complex_), expected_text="complex")
reveal_type(instantiate(path_), expected_text="Path")
reveal_type(instantiate(dataclass_), expected_text="Any")

0 comments on commit 9fa5d0b

Please sign in to comment.