types ¤
Classes:
-
EmptyDict–TypedDict with no members.
Attributes:
-
EmptyTuple–Tuple with no members.
EmptyTuple module-attribute ¤
EmptyTuple = Tuple[]
Tuple with no members.
You can use this to define a Component that accepts NO positional arguments:
from django_components import Component, EmptyTuple
class Table(Component(EmptyTuple, Any, Any, Any, Any, Any))
...
After that, when you call Component.render() or Component.render_to_response(), the args parameter will raise type error if args is anything else than an empty tuple.
Omitting args is also fine:
Other values are not allowed. This will raise an error with MyPy:
EmptyDict ¤
Bases: TypedDict
TypedDict with no members.
You can use this to define a Component that accepts NO kwargs, or NO slots, or returns NO data from Component.get_context_data() / Component.get_js_data() / Component.get_css_data():
Accepts NO kwargs:
from django_components import Component, EmptyDict
class Table(Component(Any, EmptyDict, Any, Any, Any, Any))
...
Accepts NO slots:
from django_components import Component, EmptyDict
class Table(Component(Any, Any, EmptyDict, Any, Any, Any))
...
Returns NO data from get_context_data():
from django_components import Component, EmptyDict
class Table(Component(Any, Any, Any, EmptyDict, Any, Any))
...
Going back to the example with NO kwargs, when you then call Component.render() or Component.render_to_response(), the kwargs parameter will raise type error if kwargs is anything else than an empty dict.
Omitting kwargs is also fine:
Other values are not allowed. This will raise an error with MyPy: