@@ -34,7 +34,7 @@ class AbstractComponent(abc.ABC):
34
34
if not hasattr (abc .ABC , "__weakref__" ):
35
35
__slots__ .append ("__weakref__" ) # pragma: no cover
36
36
37
- key : str
37
+ key : Optional [ Any ]
38
38
39
39
@abc .abstractmethod
40
40
def render (self ) -> VdomDict :
@@ -44,7 +44,7 @@ def render(self) -> VdomDict:
44
44
class Component (AbstractComponent ):
45
45
"""An object for rending component models."""
46
46
47
- __slots__ = "_function " , "_args" , "_kwargs"
47
+ __slots__ = "_func " , "_args" , "_kwargs"
48
48
49
49
def __init__ (
50
50
self ,
@@ -54,14 +54,14 @@ def __init__(
54
54
kwargs : Dict [str , Any ],
55
55
) -> None :
56
56
self .key = key
57
- self ._function = function
57
+ self ._func = function
58
58
self ._args = args
59
59
self ._kwargs = kwargs
60
60
if key is not None :
61
61
kwargs ["key" ] = key
62
62
63
63
def render (self ) -> VdomDict :
64
- model = self ._function (* self ._args , ** self ._kwargs )
64
+ model = self ._func (* self ._args , ** self ._kwargs )
65
65
if isinstance (model , AbstractComponent ):
66
66
model = {"tagName" : "div" , "children" : [model ]}
67
67
return model
@@ -70,14 +70,14 @@ def __eq__(self, other: Any) -> bool:
70
70
return isinstance (other , Component ) and other ._func == self ._func
71
71
72
72
def __repr__ (self ) -> str :
73
- sig = inspect .signature (self ._function )
73
+ sig = inspect .signature (self ._func )
74
74
try :
75
75
args = sig .bind (* self ._args , ** self ._kwargs ).arguments
76
76
except TypeError :
77
- return f"{ self ._function .__name__ } (...)"
77
+ return f"{ self ._func .__name__ } (...)"
78
78
else :
79
79
items = ", " .join (f"{ k } ={ v !r} " for k , v in args .items ())
80
80
if items :
81
- return f"{ self ._function .__name__ } ({ hex_id (self )} , { items } )"
81
+ return f"{ self ._func .__name__ } ({ hex_id (self )} , { items } )"
82
82
else :
83
- return f"{ self ._function .__name__ } ({ hex_id (self )} )"
83
+ return f"{ self ._func .__name__ } ({ hex_id (self )} )"
0 commit comments