Skip to content

Commit 584010a

Browse files
committed
fix(issue #1297): add annotations to tests and add str check to validation
1 parent 21a4a96 commit 584010a

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

hamilton/function_modifiers/adapters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ def validate(self, fn: Callable):
878878
f"Function: {fn.__qualname__} must have a return annotation."
879879
)
880880
origin = typing.get_origin(return_annotation)
881-
if return_annotation is not dict and origin is not dict:
881+
if return_annotation not in (dict, Dict, "dict", "dict_") and origin not in (dict, Dict, "dict", "dict_"):
882882
raise InvalidDecoratorException(f"Function: {fn.__qualname__} must return a dict.")
883883

884884
def generate_nodes(self, fn: Callable, config) -> list[node.Node]:

tests/function_modifiers/test_adapters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
from __future__ import annotations
1718

1819
import dataclasses
1920
from collections import Counter

0 commit comments

Comments
 (0)