File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ def get_type_hints(obj) -> Dict:
7878 type_hints_cache [obj ] = type_hints
7979
8080 return type_hints
81- except TypeError :
81+ except ( TypeError , NameError ) :
8282 # Return an empty dictionary when there is a TypeError. From `get_type_hints`: "TypeError is
8383 # raised if the argument is not of a type that can contain annotations, and an empty dictionary
8484 # is returned if no annotations are present"
Original file line number Diff line number Diff line change 1+ import datetime
12from typing import Optional
23from typing import get_type_hints as typing_get_type_hints
34
5+ from django_unicorn .components import UnicornView
46from django_unicorn .typer import cast_attribute_value , cast_value , get_type_hints
57from example .coffee .models import Flavor
68
@@ -23,6 +25,15 @@ def test_func(input_str):
2325 assert actual == expected
2426
2527
28+ def test_get_type_hints_gh_639 ():
29+ class MyComponentView (UnicornView ):
30+ a_date : datetime .date
31+
32+ expected = {"a_date" : datetime .date }
33+ actual = get_type_hints (MyComponentView (component_name = "test" , component_id = "123" ))
34+ assert actual == expected
35+
36+
2637class TestClass :
2738 integer : int
2839 boolean : bool
You can’t perform that action at this time.
0 commit comments