run pyright

This commit is contained in:
Khaleel Al-Adhami 2024-08-27 11:43:09 -07:00
parent e3ae1aa2b1
commit 9caccf7832
3 changed files with 16 additions and 13 deletions

View File

@ -9,9 +9,6 @@ import dataclasses
import functools import functools
import inspect import inspect
import io import io
import dill
import multiprocess
from pathos import multiprocessing, pools
import os import os
import platform import platform
import sys import sys
@ -37,6 +34,7 @@ from fastapi import FastAPI, HTTPException, Request, UploadFile
from fastapi.middleware import cors from fastapi.middleware import cors
from fastapi.responses import StreamingResponse from fastapi.responses import StreamingResponse
from fastapi.staticfiles import StaticFiles from fastapi.staticfiles import StaticFiles
from pathos import pools
from rich.progress import MofNCompleteColumn, Progress, TimeElapsedColumn from rich.progress import MofNCompleteColumn, Progress, TimeElapsedColumn
from socketio import ASGIApp, AsyncNamespace, AsyncServer from socketio import ASGIApp, AsyncNamespace, AsyncServer
from starlette_admin.contrib.sqla.admin import Admin from starlette_admin.contrib.sqla.admin import Admin
@ -50,7 +48,6 @@ from reflex.compiler import compiler
from reflex.compiler import utils as compiler_utils from reflex.compiler import utils as compiler_utils
from reflex.compiler.compiler import ( from reflex.compiler.compiler import (
ExecutorSafeFunctions, ExecutorSafeFunctions,
compile_uncompiled_page_helper,
) )
from reflex.components.base.app_wrap import AppWrap from reflex.components.base.app_wrap import AppWrap
from reflex.components.base.error_boundary import ErrorBoundary from reflex.components.base.error_boundary import ErrorBoundary
@ -180,7 +177,7 @@ class OverlayFragment(Fragment):
class UncompiledPage: class UncompiledPage:
"""An uncompiled page.""" """An uncompiled page."""
component: Component component: Union[Component, ComponentCallable]
route: str route: str
title: str title: str
description: str description: str
@ -545,8 +542,8 @@ class App(MiddlewareMixin, LifespanMixin, Base):
self.uncompiled_pages[route] = UncompiledPage( self.uncompiled_pages[route] = UncompiledPage(
component=component, component=component,
route=route, route=route,
title=title, title=title or constants.DefaultPage.TITLE,
description=description, description=description or constants.DefaultPage.DESCRIPTION,
image=image, image=image,
on_load=on_load, on_load=on_load,
meta=meta, meta=meta,
@ -1018,7 +1015,7 @@ class App(MiddlewareMixin, LifespanMixin, Base):
compile_results.append(future.get()) compile_results.append(future.get())
progress.advance(task) progress.advance(task)
for route, future in pages_futures: for _, future in pages_futures:
pages_results.append(future.get()) pages_results.append(future.get())
progress.advance(task) progress.advance(task)
@ -1027,7 +1024,7 @@ class App(MiddlewareMixin, LifespanMixin, Base):
self.pages[route] = component self.pages[route] = component
compile_results.append(compiled_page) compile_results.append(compiled_page)
for route, component in self.pages.items(): for _, component in self.pages.items():
# Add component._get_all_imports() to all_imports. # Add component._get_all_imports() to all_imports.
all_imports.update(component._get_all_imports()) all_imports.update(component._get_all_imports())

View File

@ -515,7 +515,6 @@ def purge_web_pages_dir():
if TYPE_CHECKING: if TYPE_CHECKING:
from reflex.app import UncompiledPage from reflex.app import UncompiledPage
from reflex.event import EventHandler, EventSpec
def compile_uncompiled_page_helper(route: str, page: UncompiledPage) -> Component: def compile_uncompiled_page_helper(route: str, page: UncompiledPage) -> Component:
@ -596,6 +595,8 @@ class ExecutorSafeFunctions:
Args: Args:
route: The route of the page to compile. route: The route of the page to compile.
component: The component to compile.
state: The app state.
Returns: Returns:
The path and code of the compiled page. The path and code of the compiled page.
@ -615,9 +616,13 @@ class ExecutorSafeFunctions:
Args: Args:
route: The route of the page to compile. route: The route of the page to compile.
page: The uncompiled page.
state: The app state.
style: The style of the page.
theme: The theme of the page.
Returns: Returns:
The path and code of the compiled page. The route, compiled component, and compiled page.
""" """
component = compile_uncompiled_page_helper(route, page) component = compile_uncompiled_page_helper(route, page)
component = component if isinstance(component, Component) else component() component = component if isinstance(component, Component) else component()

View File

@ -268,8 +268,9 @@ class Style(dict):
if _var is not None: if _var is not None:
# Carry the imports/hooks when setting a Var as a value. # Carry the imports/hooks when setting a Var as a value.
self._var_data = VarData.merge( self._var_data = VarData.merge(
self._var_data if hasattr(self, "_var_data") else None, _var._get_all_var_data self._var_data if hasattr(self, "_var_data") else None,
()) _var._get_all_var_data(),
)
super().__setitem__(key, value) super().__setitem__(key, value)