Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise implementation of PartialBuilds #235

Merged
merged 2 commits into from
Feb 26, 2022
Merged

Revise implementation of PartialBuilds #235

merged 2 commits into from
Feb 26, 2022

Conversation

rsokl
Copy link
Contributor

@rsokl rsokl commented Feb 26, 2022

In light of #230 this PR changes implementation of PartialBuilds to reflect that builds(<target>, zen_partial=True) can implement either the _partial_ protocol or the _zen_partial protocol. Accordingly, hydra_zen.typing now exposes two protocols: HydraPartialBuilds and ZenPartialBuilds, and PartialBuilds is their union.

Any libraries that leverage PartialBuilds in their type annotations will likely not see any breaking changes in their static analysis. However, code that used PartialBuilds to perform runtime checking will need to update their code:

e.g., from

>>> from hydra_zen.typing import PartialBuilds

>>> Conf = builds(int, zen_partial=True)
>>> isinstance(Conf, PartialBuilds)
True

to

>>> from hydra_zen.typing import HydraPartialBuilds, ZenPartialBuilds

>>> Conf = builds(int, zen_partial=True)
>>> isinstance(Conf, (HydraPartialBuilds, ZenPartialBuilds))
True

In the future (certainly not until after Hydra 1.1.2 is released), the annotations of builds may be revised to more precisely reflect when HydraPartialBuilds vs ZenPartialBuilds is returned.

@rsokl rsokl added the type-checking Involves hydra_zen.typing or pyright/mypy label Feb 26, 2022
@rsokl rsokl added this to the hydra-zen 0.6.0 milestone Feb 26, 2022
@rsokl rsokl merged commit 98d3fe2 into main Feb 26, 2022
@rsokl rsokl deleted the revise-PartialBuilds branch February 26, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-checking Involves hydra_zen.typing or pyright/mypy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant