Repository: mit-ll-responsible-ai/hydra-zen
Pull request #179 (2021-12-21 20:14:05)

pin pyright to 1.1.197 until bugfix in pyright comes through
See for upstream bug report that explains our failing CI https://github.com/microsoft/pyright/issues/2746


Patch:
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 26e88d28..e8fd9648 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -41,7 +41,7 @@ jobs:
         restore-keys: |
           ${{ runner.os }}-node-
     - name: Install pyright
-      run: sudo npm install -g pyright@">=1.1.183"
+      run: sudo npm install -g pyright@"==1.1.197"
     - uses: actions/checkout@v1
     - name: Set up Python
       uses: actions/setup-python@v2
diff --git a/.github/workflows/tox_run.yml b/.github/workflows/tox_run.yml
index 863b4081..bf92e4d7 100644
--- a/.github/workflows/tox_run.yml
+++ b/.github/workflows/tox_run.yml
@@ -159,7 +159,7 @@ jobs:
         restore-keys: |
           ${{ runner.os }}-node-
     - name: Install pyright
-      run: sudo npm install -g pyright@">=1.1.186"
+      run: sudo npm install -g pyright@"==1.1.197"
     - uses: actions/checkout@v1
     - name: Set up Python
       uses: actions/setup-python@v2
diff --git a/docs/source/api_reference.rst b/docs/source/api_reference.rst
index b5404112..3a741ac3 100644
--- a/docs/source/api_reference.rst
+++ b/docs/source/api_reference.rst
@@ -128,7 +128,7 @@ Additional Types, Supported via hydra-zen
 
 Values of additional types can be specified directly via hydra-zen's 
 :ref:`config-creation functions <create-config>`, and hydra-zen will automatically 
-create targeted configs to represent those values in a way that is compatible 
+create targeted configs to represent values those values in a way that is compatible 
 with Hydra. For example, a :py:class:`complex` value can be specified directly via :func:`~hydra_zen.make_config`, and a targeted config will be created for that value.
 
 .. code-block:: pycon
diff --git a/docs/source/changes.rst b/docs/source/changes.rst
index 88d00eb8..a426b7cf 100644
--- a/docs/source/changes.rst
+++ b/docs/source/changes.rst
@@ -5,14 +5,6 @@ Changelog
 This is a record of all past hydra-zen releases and what went into them, in reverse 
 chronological order. All previous releases should still be available on pip.
 
-.. _v0.4.1:
-
-------------------
-0.4.1 - 2021-12-06
-------------------
-
-:ref:`v0.4.0` introduced an undocumented, compatibility-breaking change to how hydra-zen treats :py:class:`enum.Enum` values. This patch reverts that change.
-
 .. _v0.4.0:
 
 ------------------
diff --git a/src/hydra_zen/structured_configs/_implementations.py b/src/hydra_zen/structured_configs/_implementations.py
index 36223266..1f1f9c23 100644
--- a/src/hydra_zen/structured_configs/_implementations.py
+++ b/src/hydra_zen/structured_configs/_implementations.py
@@ -598,11 +598,18 @@ def sanitized_default_value(
             resolved_value = conversion_fn(resolved_value)
             type_of_value = type(resolved_value)
 
+    if structured_conf_permitted and isinstance(resolved_value, Enum):
+        # Leverages programmatic access to enum member via value.
+        # E.g.
+        # >>> Color(1)
+        # <Color.RED: 1>
+        return builds(type(resolved_value), resolved_value.value)
+
     if type_of_value in HYDRA_SUPPORTED_PRIMITIVES or (
         structured_conf_permitted
         and (
             is_dataclass(resolved_value)
-            or isinstance(resolved_value, (Enum, ListConfig, DictConfig))
+            or isinstance(resolved_value, (ListConfig, DictConfig))
         )
     ):
         return resolved_value
@@ -786,8 +793,7 @@ def builds(
         The arguments specified here solely determine the signature of the resulting
         config, unless ``populate_full_signature=True`` is specified (see below).
 
-        Named parameters of the forms that have the prefixes ``hydra_``, ``zen_`` or 
-        ``_zen_`` are reserved to ensure future-compatibility, and thus cannot be
+        Named parameters of the forms that have the prefixes ``hydra_``, ``zen_`` or ``_zen_`` are reserved to ensure future-compatibility, and thus cannot be
         specified by the user.
 
     zen_partial : bool, optional (default=False)


Test patch:
diff --git a/tests/test_make_config.py b/tests/test_make_config.py
index eaf8c9bc..14de1b2c 100644
--- a/tests/test_make_config.py
+++ b/tests/test_make_config.py
@@ -155,7 +155,7 @@ def test_hydra_type_validation_works(input_type):
         instantiate(Conf, x="hi")
 
 
-@settings(max_examples=500, deadline=None)
+@settings(max_examples=500)
 @given(
     default=st.none() | st.booleans()
     # avoid issues with interpolated fields and missing values
diff --git a/tests/test_signature_parsing.py b/tests/test_signature_parsing.py
index f80b65df..aff19ce6 100644
--- a/tests/test_signature_parsing.py
+++ b/tests/test_signature_parsing.py
@@ -4,7 +4,6 @@
 import inspect
 from abc import ABC
 from dataclasses import dataclass
-from enum import Enum
 from inspect import Parameter
 from typing import Any, Callable, Dict, Mapping, Optional, Tuple, Type
 
@@ -374,16 +373,3 @@ def test_pop_full_sig_is_always_identical_to_manually_specifying_sig_args(
     note(to_yaml(Conf))
     note(to_yaml(ConfWithPopSig))
     assert to_yaml(Conf) == to_yaml(ConfWithPopSig)
-
-
-class Color(Enum):
-    red = 1
-    green = 2
-
-
-def f_with_color(x: Color = Color.red):
-    return x
-
-
-def test_populate_annotated_enum_regression():
-    assert instantiate(builds(f_with_color, populate_full_signature=True)) is Color.red
diff --git a/tests/test_value_conversion.py b/tests/test_value_conversion.py
index 8a3b83c5..049450cd 100644
--- a/tests/test_value_conversion.py
+++ b/tests/test_value_conversion.py
@@ -90,10 +90,6 @@ def test_value_supported_via_config_maker_functions(
     )
 
     if via_yaml:
-        if isinstance(value, Enum):
-            # Default omegaconf support for enums doesn't roundtrip from yamls
-            assume(False)
-
         Conf = OmegaConf.structured(to_yaml(Conf))
 
     conf = instantiate(Conf)