3232 from django .forms import Form , ModelForm
3333 from django .views import View
3434
35- from reactpy_django .types import AsyncFormEvent , SyncFormEvent
35+ from reactpy_django .types import AsyncFormEvent , SyncFormEvent , ViewToComponentConstructor , ViewToIframeConstructor
3636
3737
3838def view_to_component (
3939 view : Callable | View | str ,
4040 transforms : Sequence [Callable [[VdomDict ], Any ]] = (),
4141 strict_parsing : bool = True ,
42- ) -> Any :
42+ ) -> ViewToComponentConstructor :
4343 """Converts a Django view to a ReactPy component.
4444
4545 Keyword Args:
@@ -58,7 +58,7 @@ def constructor(
5858 * args ,
5959 key : Key | None = None ,
6060 ** kwargs ,
61- ):
61+ ) -> ComponentType :
6262 return _view_to_component (
6363 view = view ,
6464 transforms = transforms ,
@@ -72,7 +72,7 @@ def constructor(
7272 return constructor
7373
7474
75- def view_to_iframe (view : Callable | View | str , extra_props : dict [str , Any ] | None = None ):
75+ def view_to_iframe (view : Callable | View | str , extra_props : dict [str , Any ] | None = None ) -> ViewToIframeConstructor :
7676 """
7777 Args:
7878 view: The view function or class to convert, or the dotted path to the view.
@@ -88,13 +88,13 @@ def constructor(
8888 * args ,
8989 key : Key | None = None ,
9090 ** kwargs ,
91- ):
91+ ) -> ComponentType :
9292 return _view_to_iframe (view = view , extra_props = extra_props , args = args , kwargs = kwargs , key = key )
9393
9494 return constructor
9595
9696
97- def django_css (static_path : str , key : Key | None = None ):
97+ def django_css (static_path : str , key : Key | None = None ) -> ComponentType :
9898 """Fetches a CSS static file for use within ReactPy. This allows for deferred CSS loading.
9999
100100 Args:
@@ -107,7 +107,7 @@ def django_css(static_path: str, key: Key | None = None):
107107 return _django_css (static_path = static_path , key = key )
108108
109109
110- def django_js (static_path : str , key : Key | None = None ):
110+ def django_js (static_path : str , key : Key | None = None ) -> ComponentType :
111111 """Fetches a JS static file for use within ReactPy. This allows for deferred JS loading.
112112
113113 Args:
@@ -135,7 +135,7 @@ def django_form(
135135 top_children : Sequence [Any ] = (),
136136 bottom_children : Sequence [Any ] = (),
137137 key : Key | None = None ,
138- ):
138+ ) -> ComponentType :
139139 """Converts a Django form to a ReactPy component.
140140
141141 Args:
@@ -182,7 +182,7 @@ def pyscript_component(
182182 * file_paths : str ,
183183 initial : str | VdomDict | ComponentType = "" ,
184184 root : str = "root" ,
185- ):
185+ ) -> ComponentType :
186186 """
187187 Args:
188188 file_paths: File path to your client-side component. If multiple paths are \
@@ -219,7 +219,7 @@ def _view_to_component(
219219 else :
220220 _request = HttpRequest ()
221221 _request .method = "GET"
222- resolved_view : Callable = import_module (view ) if isinstance (view , str ) else view
222+ resolved_view : Callable = import_module (view ) if isinstance (view , str ) else view # type: ignore
223223
224224 # Render the view render within a hook
225225 @hooks .use_effect (
@@ -251,12 +251,12 @@ def _view_to_iframe(
251251 extra_props : dict [str , Any ] | None ,
252252 args : Sequence ,
253253 kwargs : dict ,
254- ) -> VdomDict :
254+ ):
255255 """The actual component. Used to prevent pollution of acceptable kwargs keys."""
256256 from reactpy_django .config import REACTPY_REGISTERED_IFRAME_VIEWS
257257
258258 if hasattr (view , "view_class" ):
259- view = view .view_class
259+ view = view .view_class # type: ignore
260260 dotted_path = view if isinstance (view , str ) else generate_obj_name (view )
261261 registered_view = REACTPY_REGISTERED_IFRAME_VIEWS .get (dotted_path )
262262
0 commit comments