From 2e816eab45cf08bf5d03fd34593ddb0d32354a11 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Fri, 25 Jul 2025 12:39:14 -0700 Subject: [PATCH 1/2] remove sys exception call --- reflex/utils/prerequisites.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index bfccc5e9559..586acdf02c7 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -569,13 +569,11 @@ def compile_or_validate_app( import traceback - sys_exception = sys.exception() - try: colorize = _can_colorize() traceback.print_exception(e, colorize=colorize) # pyright: ignore[reportCallIssue] except Exception: - traceback.print_exception(sys_exception) + traceback.print_exception(e) return False return True From 1016c9182c7c6de7ff844ea7c3da2ff73cf3c707 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Fri, 25 Jul 2025 12:44:45 -0700 Subject: [PATCH 2/2] remove unneeded code --- reflex/reflex.py | 7 +--- reflex/utils/prerequisites.py | 77 ++++------------------------------- 2 files changed, 10 insertions(+), 74 deletions(-) diff --git a/reflex/reflex.py b/reflex/reflex.py index f6640679535..50d0659a102 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -216,12 +216,9 @@ def _run( *args, **kwargs, ) - validation_result = compile_future.result() + compile_future.result() else: - validation_result = app_task(*args, **kwargs) - - if not validation_result: - raise click.exceptions.Exit(1) + app_task(*args, **kwargs) # Get the frontend and backend commands, based on the environment. setup_frontend = frontend_cmd = backend_cmd = None diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 586acdf02c7..856ef16e3ed 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -7,8 +7,6 @@ import functools import importlib import importlib.metadata -import importlib.util -import io import json import os import platform @@ -498,84 +496,25 @@ def compile_app( ) -def _can_colorize() -> bool: - """Check if the output can be colorized. - - Copied from _colorize.can_colorize. - - https://raw.githubusercontent.com/python/cpython/refs/heads/main/Lib/_colorize.py - - Returns: - If the output can be colorized - """ - file = sys.stdout - - if not sys.flags.ignore_environment: - if os.environ.get("PYTHON_COLORS") == "0": - return False - if os.environ.get("PYTHON_COLORS") == "1": - return True - if os.environ.get("NO_COLOR"): - return False - if os.environ.get("FORCE_COLOR"): - return True - if os.environ.get("TERM") == "dumb": - return False - - if not hasattr(file, "fileno"): - return False - - if sys.platform == "win32": - try: - import nt - - if not nt._supports_virtual_terminal(): - return False - except (ImportError, AttributeError): - return False - - try: - return os.isatty(file.fileno()) - except io.UnsupportedOperation: - return file.isatty() - - def compile_or_validate_app( compile: bool = False, check_if_schema_up_to_date: bool = False, prerender_routes: bool = False, -) -> bool: +): """Compile or validate the app module based on the default config. Args: compile: Whether to compile the app. check_if_schema_up_to_date: If True, check if the schema is up to date. prerender_routes: Whether to prerender routes. - - Returns: - If the app is compiled successfully. """ - try: - if compile: - compile_app( - check_if_schema_up_to_date=check_if_schema_up_to_date, - prerender_routes=prerender_routes, - ) - else: - validate_app(check_if_schema_up_to_date=check_if_schema_up_to_date) - except Exception as e: - if isinstance(e, click.exceptions.Exit): - return False - - import traceback - - try: - colorize = _can_colorize() - traceback.print_exception(e, colorize=colorize) # pyright: ignore[reportCallIssue] - except Exception: - traceback.print_exception(e) - return False - return True + if compile: + compile_app( + check_if_schema_up_to_date=check_if_schema_up_to_date, + prerender_routes=prerender_routes, + ) + else: + validate_app(check_if_schema_up_to_date=check_if_schema_up_to_date) def get_redis() -> Redis | None: